Hello djangoists!

Code has been coming along pretty well in my first django project.
But I hit a snag with a one-to-many relationship in my model.

When I do something like this:

    f = Foo()
    b = Bar(foo=f)
    f.save()
    b.save() # error here

I get an error like "foos_bar.foo_id may not be NULL" during b.save
().  Basically it seems to still think that f has a null ID, even
though it was issued one in the f.save() call on the line before.
Changing to this works:

    f = Foo()
    f.save()
    b = Bar(foo=f)
    b.save() # works fine

Is this expected behavior, or do I have something configured wrong?  I
was kind of hoping to create a lot of objects in memory and defer
saving any of them until all the code had finished, as a sort of poor-
man's transaction...

Thanks!
---
http://hostilefork.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to