IntegrityError when loading fixture during django testing

后端 未结 2 1615
攒了一身酷
攒了一身酷 2020-12-14 01:59

I\'m loading a fixture created with dumpdata, and getting the following exception:

Problem installing fixture \'db_dump.json\': Traceback (most recent call l         


        
相关标签:
2条回答
  • 2020-12-14 02:30

    Apparently one of the traps for the unwary is that one must exclude contenttypes when exporting fixtures. (Thanks to subsume on #django for the information).

    To exclude content types use the -e option when running the dumpdata command.

    $./manage.py dumpdata -e contenttypes > initial_data.json
    
    0 讨论(0)
  • 2020-12-14 02:32
    python manage.py dumpdata --exclude=contenttypes --exclude=auth.Permission > initial_data.json
    
    0 讨论(0)
提交回复
热议问题