【发布时间】:2015-03-04 18:45:57
【问题描述】:
我正在使用 Django 1.8b1
两个应用中有两个模型,分别称为accounts 和products
products/models.py
class ChecklistEnterpriseType(models.Model):
checklist_enterprise_type = models.CharField('Type of Enterprise', max_length=50, choices=zip(ENTERPRISE_CHOICES, ENTERPRISE_CHOICES))
def __unicode__(self):
return self.checklist_enterprise_typ
另一个模型是
accounts/models.py
class sample(models.Model):
enterprise_type = models.ForeignKey(ChecklistEnterpriseType, related_name='enterprise_type')
def __unicode__(self):
return self.enterprise_type
当我执行python manage.py makemigrations 时,它会添加迁移文件。但是当我做python manage.py migrate 时,它会引发如下错误:
raise ValueError('Related model %r cannot be resolved' % self.rel.to)
ValueError: Related model u'products.ChecklistEnterpriseType' cannot be resolved
我该如何解决这个问题。
感谢答案:)
【问题讨论】:
-
您的 INSTALLED_APPS 设置中列出的应用的顺序是什么?
-
@mishbah 订单是 INSTALLED_APPS = ('accounts', 'products',)
-
尝试交换那个。当您将模型从产品导入帐户时..
-
@mishbah 不工作的伙伴
-
您能提供完整的回溯吗?
accounts中的迁移文件是否将products列为依赖项?