Answer the question
In order to leave comments, you need to log in
Djnago - devserver makes queries to the database when returning static and media images, how to disable?
This is what each image request looks like
DEBUG 2015-08-13 10:55:47,774 14740 utils (0.000) SET SQL_AUTO_IS_NULL = 0; args=()
DEBUG 2015-08-13 10:55:47,780 14740 utils (0.000) SET SQL_AUTO_IS_NULL = 0; args=()
DEBUG 2015-08-13 10:55:47,786 14740 utils (0.000) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`session_key` = '6wi8pc3ted8yjjc3s6h4zz18s3x6irl5' AND `django_session`.`expire_date` > '2015-08-13 07:55:47'); args=('6wi8pc3ted8yjjc3s6h4zz18s3x6irl5', '2015-08-13 07:55:47')
[13/Aug/2015 10:55:47]"GET /static/images/eye-icon.png HTTP/1.1" 304 0
Answer the question
In order to leave comments, you need to log in
It seems to me that this is not due to a request for a picture, but because of a session request. What if sessions are disabled in MIDDLEWARE_CLASSES and INSTALLED_APPS?
Well, or handing out statics is not dzhangoy.
UPD : Alternatively, override process_request and process_response for django.contrib.sessions.middleware.SessionMiddleware. The code has not been tested.
from django.contrib.sessions.middleware import SessionMiddleware
class MySessionMiddleware(SessionMiddleware):
def process_request(self, request):
if request.path_info.startswith('/static/'):
return None
super(MySessionMiddleware, self).process_request(request)
def process_response(self, request, response):
if request.path_info.startswith('/static/'):
return response
return super(MySessionMiddleware, self).process_response(request, response)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question