Django templates are the presentation layer of the Django web application. A templates folder is typically created under the app directory and it has .html files. A static directory can also be created under the app directory to store images, CSS, and js files.
mysite
└── ...
myapp
└── templates
└── index.html
└── static
└── img
└── css
└── js
Django template is a mix of static HTML markups and dynamic python context dictionary. Several template tags and filters are available to render the context dictionary.
Filters can be used to enhance the value of the context key variables.
All available filters in Django templates are as follows:
Django project settings.py defines a static directory that typically houses images, CSS, and javascript files. A sample code below shows how to use the static files.
load static
In img tag use:
src = "/static/img/my_image.png"
For CSS files use under link tag:
href = "/static/css/my_stylesheet.css"
For Javascript files use under script tag:
src = "/static/js/my_script.js"