Took over a database project and I am struggling to load the remote database into the local database.
The app was built with django and the local database still relies on sqlite that comes with out of the box.
The remote database is of postgresql type.
The code I am trying to run in the terminal:
python manage.py loaddata *[path to backup.json file]*
I get some integrity error so like any reasonable man I flushed the local db because since I want to anyhows load the remote data.
python manage.py flush
python manage.py syncdata
Now when I try to load the data from the json file I get the following error:
django.db.utils.IntegrityError: Problem installing fixture 'C:...\lit\backups\dbbackup_20190915_145546.json': Could not load contenttypes.ContentType(pk=1): UNIQUE constraint failed: django_content_type.app_label, django_conten t_type.model
Changing the settings.py file from:
`DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}`
to
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'lit',
'USER': 'admin',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432'
}
just gives me a new error.
django.db.utils.IntegrityError: Problem installing fixture 'C:..\lit\backups\dbbackup_20190915_145546.json': Could not load contenttypes.ContentType(pk=17): duplicate key value violates unique constraint "django_content_type_a pp_label_model_76bd3d3b_uniq" DETAIL: Key (app_label, model)=(admin, logentry) already exists.
I already ran
python manage.py makemigrations
python manage.py migrate