Skip to content
Learn Netverks

Lesson

Step 16/36 44% through track

templates-intro

Templates introduction

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

An orientation to the Django track—how the server playground works, core vocabulary, and what you will practice next.

You need a clear map of the Django track so MVT, the ORM, and project layout do not feel like magic.

You will apply Templates introduction in contexts like: SaaS dashboards, CMS-style products, internal tools, and APIs paired with React or mobile clients.

Write Python 3 in the editor and click Run on server—the dev runner executes your script; Django framework lessons also use local startproject for full MVT (LEARNING_RUNNER_ENABLED=true). Also read the interview prep blocks.

After HTML fundamentals and basic programming concepts—before or alongside SQL.

Django templates separate presentation from Python logic. The template language is deliberately limited—no arbitrary code execution, reducing XSS risk when combined with auto-escaping.

Template syntax

{{ article.title }}
{% for article in articles %}
  <h2>{{ article.title }}</h2>
{% endfor %}
{% if user.is_authenticated %}Welcome{% endif %}

Template loading

Place templates in app/templates/app/ to avoid name clashes. Configure TEMPLATES['DIRS'] for project-wide templates. Use {% extends "base.html" %} and {% block content %} for layouts.

Important interview questions and answers

  1. Q: Logic in templates?
    A: Minimal—complex logic belongs in views or custom template tags; templates display data.
  2. Q: Auto-escaping?
    A: On by default—{{ user_input }} escapes HTML unless marked safe (careful with |safe).
  3. Q: Static vs template?
    A: Templates are rendered per request with context; static files (CSS/JS) are served as-is from static/.

Self-check

  1. What delimiter prints a variable?
  2. Why avoid heavy logic in templates?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • extends block flow?
  • autoescape XSS?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump