Bird
0
0

Find the bug in this code:

medium📝 Debug Q7 of 15
Django - Caching
Find the bug in this code:
from django.core.cache import cache
cache.set('session', 'abc123', timeout='300')
print(cache.get('session'))
Acache.set() missing value argument
Bcache.set() does not accept timeout parameter
Ccache.get() key is incorrect
Dtimeout should be an integer, not string
Step-by-Step Solution
Solution:
  1. Step 1: Check timeout parameter type

    timeout must be an integer number of seconds, not a string.
  2. Step 2: Identify type mismatch

    Passing '300' as string may cause unexpected behavior or errors.
  3. Final Answer:

    timeout should be an integer, not string -> Option D
  4. Quick Check:

    timeout parameter requires integer seconds [OK]
Quick Trick: Use integer for timeout, not string [OK]
Common Mistakes:
MISTAKES
  • Passing timeout as string
  • Confusing key names
  • Thinking timeout is unsupported

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes