Settings Cheats

This section covers the key changes that you'll need to make to your settings.py file in order to get your django-built website up and running.


Please note that this is site provides the most commonly used django features. It is by no means intended to be an exhaustive documentation of the Django framework. You can always use the official django documentation by clicking the big green button below.

Django Settings Docs

Setting Up Urls For Your App

The first major change to make to your settings file is to set register your app in your project. To do this, add <your_app_name> to the INSTALLED_APPS list in your settings.py file:

                
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    '<your_app_name>'
]

You're probably going to want to use templates, so you'll need set that up as well. The next major change to make to your settings file is to a dictionary in your TEMPLATES list. In the 'DIRS key, register your templates directory, by adding BASE_DIR / "templates" to the 'DIRS' list as illustrated below:

                
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR / "templates"
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

You're also probably going to want to use static files, so you'll need to configure this in your project. Add a STATIC_URL varibable and a STATICFILES_DIRS, and then give the values as listed below:

                
STATIC_URL = '/static/'

STATICFILES_DIRS = [
    BASE_DIR / "static",
]

Your settings.py file is now configured!