Skip to content
Justice Tech School

Templates

Templates are HTML files with Django template language. Put them in app/templates/app/ and call render() to fill them with a context dictionary.

Example
# blog/views.py
from django.shortcuts import render

def index(request):
    return render(request, "blog/index.html", {"title": "My Blog"})

# blog/templates/blog/index.html
# <h1>{{ title }}</h1>

Exercise

Render a template.

return (request, "a.html", ctx)

Quiz Test

Which function fills a template?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.