Suppose I have 2 sites that shares a common Model. What would be the best way to transfer a new Model instance created at Site A and save it in Site B's database? Could you please also recommend APIs for sending and receiving the data?
A:
Read up on Django's serialization. Basically, what you want to do is serialize to some format such as XML or JSON, send that string over, then deserialize it back to an object on the receive end.
Like much of Django, when you're done writing code you'll feel it was too easy.
Mike DeSimone
2010-04-19 04:51:26
+1
A:
The new version of Django supports multiple databases, perhaps you could setup the second database on site A then just save the model twice:
my_object.save()
my_object.save(using='database_b')
if database A always updates database B then you should look into database replication
anteatersa
2010-04-19 14:10:04