0
0
Djangoframework~10 mins

Template fragment caching in Django - Interactive Code Practice

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

Complete the code to start caching a template fragment with the key 'sidebar'.

Django
{% [1] 'sidebar' %}
Drag options to blanks, or click blank then click option'
Acache
Bload
Cinclude
Dblock
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' instead of 'cache'
Trying to use 'include' for caching
Using 'block' which is for template inheritance
2fill in blank
medium

Complete the code to end the cache block in a Django template.

Django
{% [1]cache %}
Drag options to blanks, or click blank then click option'
Astop
Bstart
Cend
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startcache' instead of 'endcache'
Using 'stopcache' or 'closecache' which are invalid
3fill in blank
hard

Fix the error in the cache tag to cache a fragment for 600 seconds with key 'menu'.

Django
{% cache [1] 'menu' %}
Drag options to blanks, or click blank then click option'
Atimeout='600'
B'600'
Ctimeout=600
D600
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around 600
Using 'timeout=600' which is invalid syntax in template tags
4fill in blank
hard

Fill both blanks to cache a fragment for 300 seconds with a variable key 'user.id'.

Django
{% cache [1] [2] %}
Drag options to blanks, or click blank then click option'
A300
Buser.id
C'user.id'
Duser_id
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting the variable key
Using a string instead of a number for timeout
5fill in blank
hard

Fill all three blanks to cache a fragment for 120 seconds with key 'product.id' and load the 'cache' template tag library.

Django
{% [1] cache %}
{% cache [2] [3] %}
Content here
{% endcache %}
Drag options to blanks, or click blank then click option'
Aload
B120
Cproduct.id
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Not loading the cache library
Quoting the variable key
Using 'include' instead of 'load'