Ethan
Ethan

Reputation: 45

Django testrunner failing with IntegrityError

When trying to run Django tests, the process fails seemingly on the admin post migrate signal. I can't find anything about this particular error. It appears that the signal is attempting to create a permission record that already exists - but I haven't modified anything with this particular model.

    Traceback (most recent call last):
    File "/Users/username/.virtualenvs/app_name/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
    psycopg2.IntegrityError: duplicate key value violates unique constraint "auth_permission_content_type_id_codename_01ab375a_uniq"
    DETAIL:  Key (content_type_id, codename)=(1, view_logentry) already exists.

Installed apps:

Installed apps:

INSTALLED_APPS = [
'admin_view_permission',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'django.contrib.messages',
# Disable Django's own staticfiles handling in favour of WhiteNoise, for
# greater consistency between gunicorn and `./manage.py runserver`. See:
# http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
'whitenoise.runserver_nostatic',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'rest_framework_xml',
'allauth',
'allauth.account',
'rest_auth.registration',
'django_extensions',
'django_celery_beat',
'django_celery_results',
'raven.contrib.django.raven_compat',
'corsheaders']

I don't have any test classes set up yet, which is why this error is particularly puzzling.

Upvotes: 1

Views: 758

Answers (1)

Juanse
Juanse

Reputation: 2583

You should remove admin_view_permission from your INSTALLED_APPS, this package is deprecated for Django 2.1

Upvotes: 6

Related Questions