0
0
Djangoframework~10 mins

Why caching matters for performance 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 import the Django cache framework.

Django
from django.core.cache import [1]
Drag options to blanks, or click blank then click option'
Acache
Bsession
Cdb
Dsettings
Attempts:
3 left
💡 Hint
Common Mistakes
Importing session or settings instead of cache.
2fill in blank
medium

Complete the code to set a value in the cache with a timeout of 300 seconds.

Django
cache.set('my_key', 'my_value', [1])
Drag options to blanks, or click blank then click option'
A300
B60
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or negative values which mean no caching or immediate expiry.
3fill in blank
hard

Fix the error in the code to retrieve a cached value safely.

Django
value = cache.[1]('my_key', default='default_value')
Drag options to blanks, or click blank then click option'
Aretrieve
Bget
Cget_value
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like fetch or get_value.
4fill in blank
hard

Fill both blanks to create a cached view decorator with a 15-minute timeout.

Django
@[1]([2])
def my_view(request):
    pass
Drag options to blanks, or click blank then click option'
Acache_page
B300
C900
Dtimeout
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong decorator names or wrong timeout values.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension caching word lengths only if length is greater than 3.

Django
lengths = {word: [1] for word in words if [2] [3] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or wrong expressions for length.