Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2019 10:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ashwingkrish/d880d4a7cd8dd21d32759a815d28bd64 to your computer and use it in GitHub Desktop.
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