Variable Routing & DTL

Django - The web framework for perfectionists with deadlines

Folder structure

1. Package folder

settings.py

Allowed hosts

ALLOWED_HOSTS = ['*']
  • '*' is a wildcard that means everything

Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'pages', #app register
]
  • Must be added every time a new app is created

Language setting & Internationalization

manage.py

  • A file that helps execute commands

  • Do not modify!

2. Apps folder

  • apps.py

    : App configuration

  • admin.py

    : Admin view

  • models.py

    : Model

  • tests.py

    : Tests

Variable routing

Use specific values in URL positions as variables

1. urls.py

2. views.py

3. template

DTL (Django Template Language)

Template files (HTML) can be structured using Django template language!

  • Django's template language is designed to strike a balance between power and ease.

  • It's designed to feel comfortable to those used to working with HTML.

Basic syntax

1. Output {{ }}

2. Syntax {% %}

Last updated