Django Cheat

Settings

postgres config

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mydatabase',
        'USER': 'mydatabaseuser',
        'PASSWORD': 'mypassword',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

load and pass environment varuables

set -o allexport; source .env.dev; set +o allexport; ./manage.py runserve

Migrate data from sqlite to postgres

./manage.py dumpdata --exclude auth.permission --exclude contenttypes > /tmp/dump.json
./manage.py shell

Enter the code below. It should fix incompatible content types, that are not supported by PostgreSQL.

from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()

Docker environment:

https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-an…

PostgreSQL

https://ioio.nu/postgresql-cheat-sheet