3👍
If it wasn’t a view, I’d have recommended this: open up an interactive shell with manage.py shell
, then do:
from django.db import connection
# execute your functions
print connection.queries
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.
0👍
You are doing it correctly. Code you wrote is for Memcached Cache not Database caching. So cache data is stored in the RAM of your server not in your database. Usually this is the fastest caching technique, but if your server doesn’t have enough memory this can crash your server and all your cached data will be lost.
For Database caching your cache settings should be configured as shown below and then your cache will be stored as a database table. Here my_cache_table being the table name.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'my_cache_table',
}
}
Read the Django cache documentation, it has very useful info.
- [Django]-With JS, jQuery, how do I save an AJAX response to a (text) file?
- [Django]-JQuery and django-rest-framework-bulk: send list
- [Django]-How to implement method in Django REST?