#30813 closed Bug (invalid)
dumpdata > flush > loaddata.
| Reported by: | Maksych | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
After commands:
python manage.py dumpdata > db.json
python manage.py loaddata db.json
All it`s okay, but after:
python manage.py flush
python manage.py loaddata db.json
Have exception:
django.db.utils.IntegrityError: Problem installing fixture 'D:\projects\python\django\ultrashop_backend\db.json': Could not load contenttypes.ContentType
Attachments (1)
Change History (4)
by , 6 years ago
| Attachment: | photo_2019-09-27_18-12-35.jpg added |
|---|
comment:1 by , 6 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
| Summary: | dumpdata > flush > loaddata → dumpdata > flush > loaddata. |
| Version: | 2.2 → master |
comment:2 by , 6 years ago
No, I tell about:
python manage.py flush
My full actions:
django-admin startproject project .
python manage.py makemigrations
python manage.py migrate
python manage.py dumpdata > db.json
python manage.py loaddata db.json
And all it's okay, but after:
python manage.py flush
python manage.py loaddata db.json
Raised exception because content-types after flush is diferent betwen after migrate.
comment:3 by , 6 years ago
This is documented behavior, please take a look at flush documentation:
Removes all data from the database and re-executes any post-synchronization handlers. The table of which migrations have been applied is not cleared. If you would rather start from an empty database and re-run all migrations, you should drop and recreate the database and then run migrate instead.
so flush removes all data from the database and re-executes post-synchronization handlers which recreates ContentType's with different IDs.
dumpdatadumps primary keys by default which don't exist anymore afterflush, so it's expected that such combination of commands fails. You should try:to avoid dumping auto primary keys (see documentation).
Closing per TicketClosingReasons/UseSupportChannels.