Django Cheatsheet

As much as Python and Django strive to be readable and strive to configure things "explicitly" rather than "implicitly" there's still a lot of code we have to remember out of thin air. This cheatsheet aims to help you there.

We try to put good stuff in this cheatsheet but it doesn't have everything! Refer to this repo to see a fully-fleshed out Django app:

https://github.com/SEI-ATL/django-todo

Creating A New Site

django-admin startproject boardgamesite
cd boardgamesite
python3 manage.py startapp boardgames

createdb boardgamesite

boardgamesite/boardgamesite/settings.py

INSTALLED_APPS = [
    'boardgames.apps.BoardgamesConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'boardgamesite',
                'HOST': 'localhost'
    }
}

TIME_ZONE = 'America/Los_Angeles'

boardgamesite/boardgamesite/urls.py

boardgamesite/boardgames/urls.py (You have to create this file yourself.)

boardgamesite/boardgames/views.py

Last updated

Was this helpful?