0
0
Djangoframework~10 mins

Why templates separate presentation in Django - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load the static tag library in Django.

Django
{% load [1] %}
Drag options to blanks, or click blank then click option'
Astatic
Burl
Ctemplate
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'static' to load static files.
Trying to load 'template' which is not a valid tag.
2fill in blank
medium

Complete the code to display a variable named 'title' in a Django template.

Django
<h1>{{ [1] }}</h1>
Drag options to blanks, or click blank then click option'
Acontent
Bname
Cheader
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not passed from the view.
Forgetting the double curly braces.
3fill in blank
hard

Fix the error in the template tag to include another template named 'header.html'.

Django
{% [1] 'header.html' %}
Drag options to blanks, or click blank then click option'
Aload
Bextends
Cinclude
Dblock
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' which is for loading tags, not templates.
Using 'extends' which is for template inheritance.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Django
{ [1]: len([2]) for [2] in words if len([2]) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen
Cwords
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'words' as the key instead of the loop variable.
Using 'len' as the loop variable.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to their values only if value is positive.

Django
result = { [1].upper(): [2] for [1], [2] in data.items() if [2] [3] 0 }
Drag options to blanks, or click blank then click option'
Akey.upper()
Bvalue
C>
Dkey
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'key.upper()' as loop variable.
Using wrong comparison operator.