Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Django - Shifting from SQLite3 to PostGres

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 dumpdata > datadump.json

Change to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

python3 migrate --run-syncdb

Run this on Django shell to exclude contentype data

python3 shell
>>> from django.contrib.contenttypes.models import ContentType
>>> ContentType.objects.all().delete()
>>> quit()


python3 loaddata datadump.json


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment