Dump existing data:
python3 manage.py dumpdata > datadump.json
Change settings.py to Postgres backend.
Make sure you can connect on PostgreSQL. Then:
python3 manage.py migrate --run-syncdb
Run this on Django shell to exclude contentype data
python3 manage.py shell
>>> from django.contrib.contenttypes.models import ContentType
>>> ContentType.objects.all().delete()
>>> quit()
Finally:
python3 manage.py loaddata datadump.json
In case anyone runs into issues like
object has no attribute '_something_cache'
: if you're using custompre_save
orpost_save
handlers you need to handle theraw=True
case in them: https://stackoverflow.com/a/19600001 https://docs.djangoproject.com/en/2.0/ref/django-admin/#what-s-a-fixture