Django:django内容类型出错

时间:2018-04-24 09:28:32

标签: django

我收到了错误:

django.db.utils.IntegrityError: insert or update on table "auth_permission" violates foreign key constraint "auth_content_type_id_508cf46651277a81_fk_django_content_type_id"
 DETAIL:  Key (content_type_id)=(1) is not present in table "django_content_type".

我找到this post但没有推荐有帮助:

ContentType.objects.clear_cache()

move 'django.contrib.contenttypes' before 'django.contrib.auth' in INSTALLED_APPS

有没有人找到解决这个问题的方法?

详细信息:my settings.py

INSTALLED_APPS = (
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.postgres',
    'webpack_loader',
    'rest_framework',
    'corsheaders',
    'common',
    'humans',
    'validations',
    'accounts',
    'comments',
    'errors',  
    'django_nose',
    'reports',
    'dashboards',
    'cacheops',
    'djcelery',
)

1 个答案:

答案 0 :(得分:1)

INSTALLED_APPS=(
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
     .....
     .....
)
你可以改变订单吗?再次重置db run migrate。