[英]Django - Abstract Base Class Model Breaking syncdb
I have this in my models.py: 我在models.py中有这个:
class AuditableTable(models.Model):
class Meta:
abstract = True
created_by = models.ForeignKey(User,blank=True,
related_name="%(app_label)s_%(class)s_related1")
last_updated_by = models.ForeignKey(User,blank=True,
related_name="%(app_label)s_%(class)s_related1")
class Company(AuditableTable): pass
I believe I am following the instructions related to abstract models mentioned here . 我相信我遵循与此处提到的抽象模型相关的说明 。
However I'm getting this error when I run manage.py syncdb: 但是,当我运行manage.py syncdb时,我收到此错误:
Error: One or more models did not validate:
ItemLocator.company: Accessor for field 'created_by' clashes with related field 'User.itemlocator_company_related1'. Add a related_name argument to the definition for 'created_by'.
ItemLocator.company: Reverse query name for field 'created_by' clashes with related field 'User.itemlocator_company_related1'. Add a related_name argument to the definition for 'created_by'.
ItemLocator.company: Accessor for field 'last_updated_by' clashes with related field 'User.itemlocator_company_related1'. Add a related_name argument to the definition for 'last_updated_by'.
ItemLocator.company: Reverse query name for field 'last_updated_by' clashes with related field 'User.itemlocator_company_related1'. Add a related_name argument to the definition for 'last_updated_by'.
I'm on Django 1.2. 我在使用Django 1.2。
Your related_name for created_by and last_updated_by are the same and should not be. 您对created_by和last_updated_by的related_name是相同的,不应该是。
for what I can see your class Meta is ok, just change the related_name :) 因为我可以看到你的类Meta是好的,只需更改related_name :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.