How to manage load.data files in Django

I have been fighting this team for several hours.

If i do

python manage.py dumpdata --natural-foreign --> data.json

when i load data i get error

Failed to load contenttypes.ContentType (pk = 19): duplicating a key value violates the unique "django_content_type_app_label_76bd3d3b_uniq" constraint DETAILS: Key (app_label, model) = (misuper, stockitem) already exists.

Then if I do

python manage.py dumpdata --natural-foreign --exclude=contenttypes --> data.json

I get a similar error, but with object ̣ auth.Permission:

Failed to load auth.Permission (pk = 55): duplicate key value violates the unique restriction "auth_permission_content_type_id_01ab375a_uniq"

And if I do

python manage.py dumpdata --natural-foreign --exclude=contenttypes --exclude=auth --> data.json

When I load data, I get

User match request does not exist

Of course, I exclude the auth table.

... WTF , ? .

, . , , .

+4
1

:

python manage.py dumpdata --natural-foreign \
   --exclude auth.permission --exclude contenttypes \
   --indent 4 > data.json
+9

Source: https://habr.com/ru/post/1669206/


All Articles