At first glance, I'd guess it's because the PK for ringo and beatles haven't been updated in the instances you have.
On 22 November 2013 16:31, Adam Smith <[email protected]> wrote: > As I was learning the Django Docs ( > https://docs.djangoproject.com/en/1.6/topics/db/models/#extra-fields-on-many-to-many-relationships), > I found the following code not working. Is it a bug? At least the result is > unexpected. > > ringo = Person(name="Ringo") > beatles = Group(name="Beatles") > m1 = Membership(person=ringo, group=beatles, > date_joined=date.today(), > reason='whatever') > ringo.save(), beatles.save() > print m1.person.id, m1.group.id # yes, they have values. > m1.save() # IntegrityError: membership.person_id may not be NULL > > > Why can't m1 be save, since both its foreign key fields have been save > successfully? > > Thanks. > > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/1d4d456f-abff-48fe-bf4c-0014c50abe9c%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAG_XiSDH7KqXhJCdEdo7QGGOhD7P3hubKLSYEgpu%3D8VBaXHQEA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
