Django templates

Django templates

Django templates — Contains the static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.

Django templates — Text document or a Python string marked-up using the Django template language.

{% if user.is_authenticated %}Hello, {{ user.username }}.{% endif %}

The template system isn’t safe against untrusted template authors. For example, a site shouldn’t allow its users to provide their own templates, since template authors can do things like perform XSS attacks and access properties of template variables that may contain sensitive information.

Configuration

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            # ... some options here ...
        },
    },
]

Templates engines are configured with the TEMPLATES setting.

Django templates — Structure map

Clickable & Draggable!

Django templates — Related pages: