Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django tests loading fixtures auth.group

When I run django tests I get the error:

IntegrityError: Problem installing fixture ... ContentType matching query does not exist.: (auth.group:pk=2) field_value was '[u'add_corsmodel', u'corsheaders', u'corsmodel']'

I get the fixtures by doing

python manage.py dumpdata --natural-foreign --exclude=contenttypes --exclude=auth.Permission

How can I solve this? should I exclude some other table?

like image 379
Alejandro Veintimilla Avatar asked Sep 02 '25 10:09

Alejandro Veintimilla


1 Answers

well I tried to do one simple thing to add permissions. I've created a .json file and put in data.

[
  {
    "model": "auth.group",
    "fields": {
      "name": "foo",
      "permissions": [
        29,45,46,47,48 //permission ID's created in auth.group
      ]
    }
  },
  {
    "model": "auth.group",
    "fields": {
      "name": "new_grp",
      "permissions": [
        29,45,46,47,48
      ]
    }
  }
]

this is my initial permissions that I want to include and then

 manage.py loaddata <myJsonFIle>

i think in your case it is not able to find the rows or columns in the table that's why it shows IntegrityError

like image 197
Kalariya_M Avatar answered Sep 04 '25 04:09

Kalariya_M