How to Prevent Django Device Compatibility with Existing Data

I am trying to do manage.py loaddata myfixture.json to deliberately overwrite multiple records in my database. However, this gives me an error:

 IntegrityError: Problem installing fixture 'myfixture.json': Could not load myapp.Person(pk=1): (1062, "Duplicate entry 'Bob' for key 'name'") 

I thought the behavior of loaddata was to overwrite records if the primary key matches an existing record? Am I mistaken, or was this changed in Django 1.5? How do I rewrite it?

+6
source share
2 answers

I found a way to modify the Django loaddata command to correctly parse natural keys at boot time and avoid duplicate reloading. The modified team is published here . The only differences between the official loaddata are lines 189-201.

+4
source

Perhaps if you create a team and call it, you can handle the situation.

In my opinion, luminaires are designed for static data.

+1
source

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


All Articles