On Mon, 2009-03-09 at 21:13 -0700, Brian wrote:
> I'm having trouble saving deserialied model objects. My setup is that
> I have two django instances, let's call them A and B. The intial
> request comes into server A which then serializes some objects and
> sends them off to server B for the results of some computation. When
> server B tries to save the objects sent by A it fails.
> 
> I believe the save is failing because the objects already have primary
> keys set from server A's database, but are not contained in server B's
> database. I could be wrong that this is the reason.

So why not test that theory? You have an hypothesis. Now prove or
disprove.

Put in some debugging printing or logging on the B side and see if the
objects have the "pk" value set. If B doesn't set them and that value is
meant to represent something in the database and the database is meant
to set that value (as part of an auto-increment sequence), then that's
your problem. If the "pk" value isn't set, you know it isn't the
problem.

If it is the problem, one solution would be to make the primary key on
the B side (if it needs to match the value on the A side) not be an
auto-incrementing sequence. Just make it an integer so that you can set
it yourself. It will mean having slightly different model definitions on
the A and B side, but that's life in the big city. If you want the
models to be the same, you'll need to remove the pk value before saving
(set it to None).

Regards,
Malcolm


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

Reply via email to