Opened 3 years ago
Last modified 3 years ago
#33427 closed New feature
Add new flag in loaddata command that loads fixture without overriding existing objects with same primary key — at Initial Version
Reported by: | Mohit Solanki | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | loaddata, fixture, command |
Cc: | me@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Installing fixtures with django's loaddata
command overrides objects with the same primary key.
While this is not a problem if you are installing the fixtures against a fresh DB with no data but in case you have
existing data then loading the fixture can be problematic as all the existing rows with the same primary key will be updated
with the new data from the fixture(s)
It would be a good idea to have an additional flag that for e.g --insert-only
or something that tells django not to override existing objects with the same primary key.
Note: I created this package https://github.com/mohi7solanki/dj-snake to solve this issue but I think It would be a good idea to add this functionality to loaddata
itself