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?
for contact in participant.person.mailcontact_set.all():
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With