【发布时间】:2014-01-02 20:09:20
【问题描述】:
我无法修改或删除我的Parameter 模型,因为schemamigration 命令以某种方式使用了它。其他型号一切正常。
当我删除 Parameter.name 字段并运行 schemamigration my_app --auto 命令时,我得到:
FieldError: Unknown field(s) (name) specified for Parameter
当我删除模型并运行 schemamigration my_app --auto 命令时,我得到:
ImportError: cannot import name Parameter
我的models.py:
class Parameter(models.Model):
algorithm = models.ForeignKey(Algorithm, related_name='parameters',
null=True, blank=True,
verbose_name=_('Algorithm'))
name = models.CharField(_('Option'), max_length=255, null=True)
required = models.BooleanField(_('Required'), blank=True)
default = models.CharField(_('Default'), max_length=255,
null=True, blank=True)
label = models.CharField(_('Label'), max_length=255, null=True, blank=True)
description = models.TextField(_('Description'), null=True, blank=True)
description_lt = models.TextField(_('Description LT'), null=True, blank=True)
我怎样才能找出问题所在?我该如何解决?
【问题讨论】:
-
您是否在特定应用程序上调用架构迁移?还是您为所有应用程序运行它? (schmamigration app_name)?您是否也在运行初始架构迁移?还是汽车?
-
@petkostas 我运行
schemamigration my_app --auto。 -
您的设置中是否有已安装应用程序中的参数?
-
@petkostas 是的,
Parameter在my_app/models.py中,my_app被添加到 settings.pyINSTALLED_APPS字典中。 -
您的 admin.py 中是否也注册了 name 字段(例如在字段集中)?
标签: python django django-models django-south