I have models A and B, with B having an FK(null=False) to A.  If I
create a new instance of A, I have a post_save handler that
potentially creates instances of B that point to the new A object.

This works fine under normal circumstances, but when I'm loading a
test fixture and this handler gets triggered, I get an IntegrityError
like: "B.fk_id my not be NULL".  Sure enough, the object's pk
attribute is set, but id isn't.

The loaddata command appears to do a "raw" save on all the objects.
Is this the reason that the id attribute doesn't get set on the
instance?  Shouldn't post_save be providing me a "proper" instance of
the model, as though it came from the db?

Perhaps most importantly: what should I do to work around this issue?
It looks like Model.save_base sends a "raw" flag with post_save, but
it isn't documented, and the save_base documentation indicates that
"raw" is intended to be for internal use only.  I'm guessing it's not
kosher to check that parameter in the post_save handler.
--~--~---------~--~----~------------~-------~--~----~
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