Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display the variable username in a Django template.
Django
<p>Hello, {{ [1] }}!</p> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single braces instead of double braces.
Misspelling the variable name.
✗ Incorrect
In Django templates, variables are displayed using double braces like {{ username }} to show the value of the variable named 'username'.
2fill in blank
mediumComplete the code to show the email variable inside a paragraph in a Django template.
Django
<p>Your email is: {{ [1] }}</p> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names.
Forgetting the double braces.
✗ Incorrect
To display the email variable, use {{ email }} inside the template.
3fill in blank
hardFix the error in the template code to correctly display the title variable.
Django
<h1>{{ [1] }}</h1> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one closing brace instead of two.
Using wrong variable names.
✗ Incorrect
The template variable must be enclosed in double braces on both sides. The code is missing one closing brace. The correct variable is 'title'.
4fill in blank
hardFill both blanks to display the first_name and last_name variables separated by a space.
Django
<p>{{ [1] }} {{ [2] }}</p> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single variable like 'fullname' instead of separate first and last names.
Forgetting the double braces.
✗ Incorrect
To show first and last names, use {{ first_name }} and {{ last_name }} with a space between them.
5fill in blank
hardFill all three blanks to display the user object's username, email, and age properties.
Django
<p>Username: {{ [1] }}</p>
<p>Email: {{ [2] }}</p>
<p>Age: {{ [3] }}</p> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'user.name'.
Forgetting the double braces or dot notation.
✗ Incorrect
To access properties of an object in Django templates, use dot notation like {{ user.username }}, {{ user.email }}, and {{ user.age }}.