Traceback (most recent call last):
File "/usr/local/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/virenv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/virenv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 161, in __call__
status = '%d %s' % (response.status_code, response.reason_phrase)
File "/virenv/lib/python2.7/site-packages/django/http/response.py", line 69, in reason_phrase
if self._reason_phrase is not None:
AttributeError: 'TemplateResponse' object has no attribute '_reason_phrase'
I am completely clueless why the above exception is occurring. I do not have any other data or logs for the above exception
Could anyone help me in providing a way to debug the above?
Thanks.
def cache_per_user_method(ttl=None, prefix=None, cache_post=False):
'''
Decorator which caches the view for each User
* ttl - the cache lifetime, do not send this parameter means that the cache
will last until the restart server or decide to remove it
* prefix - Prefix to use to store the response in the cache. If not informed,
it will be used 'view_cache _' + function.__ name__
* cache_post - Determine whether to make requests cache POST
* The caching for anonymous users is shared with everyone
How to use it:
@cache_per_user_method(ttl=3600, cache_post=False)
def get(self, request):
...
'''
def decorator(view_method):
def apply_cache(obj, request, *args, **kwargs):
CACHE_KEY = cache_key(request, prefix)
logger.debug("cache key %s",CACHE_KEY)
# Verifica se pode fazer o cache do request
if not cache_post and request.method == 'POST':
can_cache = False
else:
can_cache = True
if can_cache:
response = core_cache.get(CACHE_KEY, None)
else:
response = None
if not response:
response = view_method(obj, request, *args, **kwargs)
logger.debug("cache not found in decorator")
if can_cache and hasattr(response, 'render'):
logger.debug("cache set in decorator")
core_cache.set(CACHE_KEY, response.render(), ttl)
return response
return apply_cache
The above code was causing the error to happen but couldn't figure out where the issue was in the above.
Thanks,