Here's the scenario:
I'm using django's admin interface and I would like to be able to load users and groups via fixtures (if this is possible.) I'm able to dump users/groups like so:
manage.py dumpdata auth auth.group > usersandgroups.json
But upon loading the data in a brand new database...
manage.py loaddata <appname>/fixtures/usersandgroups.json
I get all sorts of errors having to do with foreign keys and such. Here's an example of one:
django.db.utils.IntegrityError: insert or update on table "auth_permission" violates foreign key constraint "content_type_id_refs_id_728de91f"
DETAIL: Key (content_type_id)=(37) is not present in table "django_content_type".
I'd really appreciate it if anyone could point me in the right direction. Thanks in advance!
You're including more than just user and groups in your dump -- namely, permissions as well. You're getting a conflict because of the permissions. Since you don't need those, just get rid of them from your fixture.
manage.py dumpdata auth.User auth.Group > usersandgroups.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With