【问题标题】:South schemamigration command depends on edited modelSouth schemamigration 命令取决于编辑的模型
【发布时间】: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 是的,Parametermy_app/models.py 中,my_app 被添加到 settings.py INSTALLED_APPS 字典中。
  • 您的 admin.py 中是否也注册了 name 字段(例如在字段集中)?

标签: python django django-models django-south


【解决方案1】:

从上面的错误看来,您正在使用管理实例或表单实例注册模型和字段在其中任何一个中。

【讨论】:

    猜你喜欢
    • 2011-05-12
    • 2012-04-18
    • 2011-06-05
    • 2013-05-14
    • 1970-01-01
    • 2013-05-03
    • 1970-01-01
    • 2012-08-13
    • 1970-01-01
    相关资源
    最近更新 更多