Question 1
What does a Django template do in a view?
Runs Python code directly
Mixes HTML with dynamic data
Creates database tables
Handles URL routing
Question 2
In a view, what sends data to a template?
HttpResponse('home.html')
include('home.html')
redirect('home.html')
render(request, 'home.html')
Question 3
What starts Django code in templates?
{{ variable }} for output
# comment # for notes
{% tag %} for logic
All of the above
Question 4
How to show a list item like posts.0.title?
{% posts[0].title %}
{{ posts.0.title }}
# posts.0 #
{{ posts.title[0] }}
Question 5
What does {% url 'home' %} do in a template?
Runs a view function
Loops over items
Filters text
Links to a named URL
Question 6
What shows content only if user.is_authenticated?
{{ if user }} Hi! {{ endif }}
# if user Hi! #
{% user %} Hi! {% enduser %}
{% if user.is_authenticated %} Hi! {% endif %}
Question 7
How to check if score > 10 and level == 'hard'?
{% if score > 10 and level == 'hard' %}
{{ score > 10 or level == 'hard }}
{% if score > 10 or level == 'hard' %}
{% score and level %}
Question 8
What loops over a list of fruits?
# for fruit #
{{ for fruit in fruits }} {{ fruit }} {{ endfor }}
{% for fruit in fruits %} {{ fruit }} {% endfor %}
{% fruits %} {{ fruit }} {% endfruits %}
Question 9
What shows "No results" if a list like items is empty?
{% empty %} No results {% endempty %} inside for
{% if not items %} No results {% endif %}
{{ items.empty }}
{% for empty %}
Question 10
What makes text uppercase like {{ name|upper }}?
{% upper name %}
{{ name.upper }}
Applies upper filter to name
# name | upper #
There are 15 questions to complete.