B
B
Bjornie2018-04-16 11:05:39
PostgreSQL
Bjornie, 2018-04-16 11:05:39

How to neatly move some records from one db to another in Django?

There are two servers (test and prod), on the test there is some data that needs to be moved to prod. This is a chain of related data (user, profile, cart, model A, model B), so it is desirable to extract everything together and load it back together.
A small nuance: PK must also be placed somehow without conflict.
Any ideas how it's done? Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2018-04-16
@sim3x

https://docs.djangoproject.com/en/2.0/topics/migra...

P
Pavel Aksenov, 2018-04-16
@hellmin

It is necessary to slightly correct the models or rather add managers to the models. Add relationship serialization rule get_by_natural_key() https://docs.djangoproject.com/en/2.0/topics/seria... . Then dumpdata on test and loaddata on production.
For such dances, it is better to make a separate branch to transfer data, and then delete it and forget it like a bad dream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question