I am trying to migrate my django project from sqlite3 to postgresql. I have done this succesfully in development but getting errors in production.
i have used this command to create dumps:
manage.py dumpdata --exclude auth.permission --exclude contenttypes > db.json
then i changed database in my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dbname',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432',
}
then i exclude contenttypes as follow:
python3 manage.py shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()
but i am getting this error:
django.db.utils.IntegrityError: Problem installing fixtures: insert or update on table
"django_admin_log" violates foreign key constraint
"django_admin_log_content_type_id_c4bce8eb_fk_django_co"
DETAIL: Key (content_type_id)=(7) is not present in table "django_content_type".
please help
ContentTypes... SoGenericForeignKeys will no longer work, since the table is empty and you thus can no longer refer to aContentType...ContentType.objects.all().delete()but its still raising error, is there any other way?ContentTypes in the first place?ContentType.objects.clear_cache()