![](/img/trans.png)
[英]Django objection creation failing due to FOREIGN KEY constraint failure (IntegrityError )
[英]Django testrunner failing with IntegrityError
嘗試運行 Django 測試時,該過程似乎在管理后遷移信號上失敗。 我找不到有關此特定錯誤的任何信息。 信號似乎試圖創建一個已經存在的權限記錄 - 但我沒有用這個特定的模型修改任何東西。
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 = [
'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']
我還沒有設置任何測試類,這就是為什么這個錯誤特別令人費解的原因。
你應該從你的INSTALLED_APPS
刪除admin_view_permission
,這個包已被 Django 2.1 棄用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.