Reputation: 6254
I have these models:
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
in views.py
:
emails = []
for participant in participants:
for contact in participant__person__mailContact_set:
emails.append(contact.email)
send_mail(email_subject,email_body,'[email protected]',emails,fail_silently=False)
I've changed this code in many ways but I'm repeatedly get this error:
global name 'participant__person__mailContact_set' is not defined
any suggestion?
Upvotes: 14
Views: 6603