Install Python
Create a simple Django project
django_templates
folder in the current directory, and all the necessary files for a basic, but fully functioning Django website with an SQLite database. Being a batteries-included
framework, Django scaffolds the project with working authentication and administration modules out-of-the-box. To use any of these default features a migration should be executed to create the necessary tables. 8000
. settings.py
file and should look quite similar to this code chunk: For simplicity, thetemplates
folder will be created in the root of the project
Updated configuration
templates
directory. {% if %}...{% endif %}
{% for x in y %}...{% endfor %}
{% include "header.html" %}
{% extends "base.html" %}
{% block content %}...{% endblock %}
Variables and lists
Filters - simple helpers useful to transform the information directly in the template
upper
, default value
, string truncation
Comments in Django templates
{% comment %}
and {% endcomment %}
Conditionals - useful to test a variable presence or value
Loops - how to iterate on lists
Imports - components reuse
Template Inheritance - allows toextend
template with specific information
page title
, highlight the active menu and other things specific to the current page.base.html
in the templates directoryextends
the base templatechild.html
, the { extends }
block informs the engine to merge the base.html
template with the content provided by child.html
. { block title }
becomes MySample{ block content }
becomes Cool content here