转储的数据python manage.py dumpdata --format json --indent 4 --exclude auth.permission --exclude contenttypes > app/fixtures/app_test_data.json
运行python manage.py测试应用时,我得到以下错误:
IntegrityError: Problem installing fixtures: The row in table 'django_admin_log' with primary key '517' has an invalid foreign key: django_admin_log.content_type_id contains a value '28' that does not have a corresponding value in django_content_type.id.有什么想法吗?我在使用dumpdata/Django的测试跑步器时遇到了很多类似的问题。
发布于 2017-01-07 02:13:41
如果:
您可以使用文本编辑器恢复json中捕获的信息,打开文件并删除与admin.logentry模型关联的元素。
这对我很有效!
发布于 2015-11-07 22:09:15
如果像在示例中那样排除contenttype应用程序,则可能无法导出具有该应用程序的前缀键的任何应用程序。移除--exclude contenttypes可能会使其正常工作。
https://stackoverflow.com/questions/19415558
复制相似问题