使用固定装置将 django admin auth.groups 和用户迁移到新数据库
这是场景:
我正在使用 django 的管理界面,我希望能够通过固定装置加载用户和组(如果可能的话)。我能够像这样转储用户/组:
manage.py dumpdata auth auth.group > usersandgroups.json
但是在加载数据时一个全新的数据库...
manage.py loaddata <appname>/fixtures/usersandgroups.json
我遇到了与外键等有关的各种错误。这是一个例子:
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".
如果有人能指出我正确的方向,我将非常感激。提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在转储中不仅仅包含用户和组,即权限。由于权限问题,您会遇到冲突。由于您不需要这些,只需将它们从您的固定装置中删除即可。
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.