Since i'm new to django-cache, I was trying to cache a particular view in Django. I'm not sure whether the data is fetched from cache or from the database. How do I verify that? Being a newbie, kindly also check that I'm caching the view correctly or not?
Views.py
@cache_page(900)
def dashboard(request):
__something__
Settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 600
If it wasn't a view, I'd have recommended this: open up an interactive shell with
manage.py shell
, then do:This list will fill up with SQL queries as you execute them.
But since it's a view, I'd recommend you to use django-debug-toolbar. Besides other useful things, it'll show you the queries executed while handling the request.