这是我的生产模型(在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)
当我尝试与south进行schemamigration时,出现以下错误消息:
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中。这两个应用程序已经由南方管理。
感谢托马斯·奥罗斯科(Thomas Orozco),我确实发现了我的错误!这行是不正确的:
network = models.ManyToManyField('selfcare.apps.auth.models.Network')
我这样纠正:
network = models.ManyToManyField('auth.Network')
然后迁移确实与南方合作了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句