Complete the code to import the Django cache framework.
from django.core.cache import [1]
The cache object is imported from django.core.cache to use caching features.
Complete the code to set a value in the cache with a timeout of 300 seconds.
cache.set('my_key', 'my_value', [1])
The timeout value 300 means the cached data will expire after 5 minutes.
Fix the error in the code to retrieve a cached value safely.
value = cache.[1]('my_key', default='default_value')
The correct method to get a cached value with a default is get.
Fill both blanks to create a cached view decorator with a 15-minute timeout.
@[1]([2]) def my_view(request): pass
cache_page is the decorator to cache a view, and 900 seconds equals 15 minutes.
Fill all three blanks to create a dictionary comprehension caching word lengths only if length is greater than 3.
lengths = {word: [1] for word in words if [2] [3] 3}The comprehension stores the length of each word if its length is greater than 3.