Django: Error with django content type
NickName:Lola Ask DateTime:2018-04-24T17:28:31

Django: Error with django content type

I got error:

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".

I found this post but no recommendation helps:

ContentType.objects.clear_cache()

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

Has anyone found a solution to this problem?

For details: 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',
)

Copyright Notice:Content Author:「Lola」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49998053/django-error-with-django-content-type

More about “Django: Error with django content type” related questions

Django: Error with django content type

I got error: 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: ...

Show Detail

django migration error (django_content_type)

I am trying to do a --fake-initial migration in django (1.9.7), but it gives me a strange error: django.db.utils.OperationalError: (1054, "Unknown column 'name' in 'django_content_type'") as far ...

Show Detail

django_content_type error in django seo2

I am working on a Django(1.8) project. I am trying to implement django-seo2. Integrated Travis CI on GitHub for continuous integration. I keep getting the following error on Travis: ProgrammingEr...

Show Detail

Django 1.8 migrate: django_content_type does not exist

I just upgraded my django from 1.7.1 to 1.8.4. I tried to run python manage.py migrate but I got this error: django.db.utils.ProgrammingError: relation "django_content_type" does not exist I drop...

Show Detail

Upgrade django-synchro for django 2.2 : OperationalError - no such table: django_content_type"

I am trying to upgrade django-synchro to django 2.2. I have already upgraded the project to django 2.1 but I have now a problem with ContentType object The upgraded version to django 2.1 can be fo...

Show Detail

Django 1.8 create table before reference django_content_type and then fails

I'm trying to create ContentType reference (https://docs.djangoproject.com/en/1.8/ref/contrib/contenttypes/#generic-relations) myobj/models.py: from django.db import models from django.contrib.

Show Detail

content type headers from multipart in django

I have a django endpoint that gets a multipart and I want look at the content type headers in each part. When I look at request.META['CONTENT_TYPE'] I get: 'multipart/form-data; boundary="boundary...

Show Detail

Django 1.8 migrate - relation "django_content_type" already exists

Any idea why I would be getting this error when I try to migrate? django.db.utils.ProgrammingError: relation "django_content_type" I am using using Django 1.8 & PostgreSql

Show Detail

Could Django be getting wrong content_type_id for a model?

When I edit an object (user 276) in django-admin, I get a foreign key error: IntegrityError at /admin/auth/user/276/change/ (1452, 'Cannot add or update a child row: a foreign key constraint fail...

Show Detail

Django: FileField, missing content_type

If I read the docs correctly, then the FileField in Django does not know the content_type of the file: https://docs.djangoproject.com/en/2.1/ref/models/fields/ I would like to store files in a Dja...

Show Detail