To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fe0288b9-9382-4163-b2cd-9d998f2e72f3%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
>>> p.first_name = 'aaa'
>>> p.last_name = 'bbb'
<Person: bbb, aaa>
>>> p.emails.all()
[]
>>> p.emails.count()
0
>>> p.emails.create(email='a...@aaa.aaa')
Traceback (most recent call last):
File "<console>", line 1, in <module>
...
(value, self.field.rel.to._meta.object_name)
ValueError: Cannot assign "<Person: bbb, aaa>": "Member" instance isn't saved in the database.
>>> p.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
...
raise ValueError('Need at least one e-mail.')
ValueError: Need at least one e-mail.
I liked the idea at first but after couple tests realized that the it will alway raise the error on save().The problem is that I can't add any Email without Person, this looks great but, I also can't add a Person without an Email and so it will never allow me to add anything.Maybe I should keep it as ForeignKey but ensure that the Email is filled just in the form validation, not on database/class level? Following a test that i did:>>> p = Person()
>>> p.first_name = 'aaa'
>>> p.last_name = 'bbb'
<Person: bbb, aaa>
>>> p.emails.all()
[]
>>> p.emails.count()
0
>>> p.emails.create(email='aaa@aaa.aaa')