这是我在制作中的模型(在selfcare.apps.support.models中):
class Document(models.Model):
CATEGORY_CHOICES = (
('HSI', _('Internet')),
('ITV', _('Television')),
('VOIP', _('Phone')),
('MAIL', _('Email')),
)
title = models.CharField(max_length=100, db_index=True)
start_date = models.DateTimeField(default=datetime.datetime.now)
end_date = models.DateTimeField(blank=True, null=True)
active = models.BooleanField(default=True)
category = models.CharField(max_length=10, choices=CATEGORY_CHOICES)
document = models.FileField(upload_to='support_documents')
我想在现有的Document模型中添加以下行:
network = models.ManyToManyField('selfcare.apps.auth.models.Network')
以下是Network类的模型(在selfcare.apps.auth.models中):
class Network(selfcare.libs.core.utils.SettingHelper, models.Model):
name = models.CharField(max_length=100, db_index=True)
code = models.CharField(max_length=20, db_index=True, default='')
operator = models.ForeignKey(Operator)
setting = generic.GenericRelation(Setting)
def __unicode__(self):
return "%s - %s" % (self.code, self.operator.code)
当我尝试使用南方的模式移植时,我收到以下错误消息:
CommandError: One or more models did not validate:
support.document: 'networks' has an m2m relation with model selfcare.apps.auth.models.Network, which has either not been installed or is abstract.
这两个应用都在INSTALLED_APP中。 这两个应用程序都已由南方管理。
答案 0 :(得分:1)
感谢Thomas Orozco,我确实发现了我的错误! 这条线不正确:
network = models.ManyToManyField('selfcare.apps.auth.models.Network')
我这样纠正:
network = models.ManyToManyField('auth.Network')
然后迁移确实与南方合作!