在djang中迭代相关对象

2024-10-01 13:38:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这些型号:

class Person(models.Model):
   name=models.CharField(max_length=100)
   family=models.CharField(max_length=100)

class MailContact(models.Model):
   person=models.ForeignKey(Person)
   email=models.CharField(max_length=100)
   #some fields

class Participant(models.Model):
   person=models.ForeignKey(Person)
   #some fields

views.py中:

^{pr2}$

我已经以多种方式更改了此代码,但我反复遇到以下错误:

global name 'participant__person__mailContact_set' is not defined

有什么建议吗?在


Tags: namefieldsmodelmodelssomefamilylengthmax