私は現在、複数のレガシーを行う必要があるdjangoプロジェクトに取り組んでいます。プロジェクト自体には、複数の Web サイトを持つ管理者がいます。私の管理部分では、メンバーのすべての必須情報を含む Member クラスを作成しました。次に、すべての個々のサイトには、すべての補足情報を追加する管理者の Member クラスから作成された MemberExtra クラスがあります。サーバーを起動すると(python manage.py runserver ...)、そのエラーが発生しました:
Error: One or more models did not validate:
programsite.memberextra: Accessor for field 'member_ptr' clashes with related field 'Member.memberextra'. Add a related_name argument to the definition for 'member_ptr'.
programsite.memberextra: Reverse query name for field 'member_ptr' clashes with related field 'Member.memberextra'. Add a related_name argument to the definition for 'member_ptr'.
gourmandiz.memberextra: Accessor for field 'member_ptr' clashes with related field 'Member.memberextra'. Add a related_name argument to the definition for 'member_ptr'.
gourmandiz.memberextra: Reverse query name for field 'member_ptr' clashes with related field 'Member.memberextra'. Add a related_name argument to the definition for 'member_ptr'.
管理者/models.py:
class Member(models.Model):
prog = models.ForeignKey(Program, verbose_name=_("Program"))
status = models.CharField(_("Status"), m status = models.CharField(_("Status"), max_length=1, choices=STATUS_CHOICE\
S)
points_avai = models.BigIntegerField(_("
Current Points"), null=True)
points_notavai = models.BigIntegerField(_("Future Points"), null=True)
cn = models.CharField(_("Company name"), max_length=250)
full_name = models.CharField(_("Full name"), max_length=250)
b_add = models.CharField(_("Billing address"), max_length=250)
b_city = models.CharField(_("Billing City"), max_length=250)
b_zip = models.CharField(_("Billing ZIP code"), max_length=250)
b_country = models.CharField(_("Billing country"), max_length=250)
prog_start_date = models.DateField(_("Program start date"), null=True)
prog_end_date = models.DateField(_("Program end date"), null=True)
member_id = models.CharField(_("Member ID"), max_length=250, primary_key=T\
rue)
client_id = models.CharField(_("Client ID"), max_length=250, help_text="Nu\
méro de client.")
user = models.OneToOneField(User)
def __unicode__(self):
return self.full_name + " (" + str(self.member_id) + ")"
class Meta:
verbose_name = _("Member")
verbose_name_plural = _("Members")
programsite/models.py:
class MemberExtra(Member):
email = models.EmailField(_("Email"), max_length=100, null=True)
tel = models.CharField(_("Tel"), max_length=100, null=True)
patrick = models.CharField(_("Patrick"), max_length=100, null=True)
test42 = models.CharField(_("Test42"), max_length=100, null=True)
gourmandiz/models.py:
class MemberExtra(Member):
email = models.EmailField(_("Email"), max_length=100, null=True)