Django was working normally, suddenly I wasn't able to get any debugging messages. I have been commenting out my code to see which part is causing that and it turned out to be my last_visit middleware which gets when was the last time user visited the app. But why? what is wrong with it?!
last_visit.py (The middleware I made)
from django.http import HttpResponse
from django.utils.timezone import now
from django.contrib.auth import get_user_model
User = get_user_model()
class SetLastVisitMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if request.user.is_authenticated:
User.objects.filter(id=request.user.id).update(last_visit=now())
return self.get_response(request)
def process_exception(self, request, exception):
return HttpResponse("in exception")
settings.py:
MIDDLEWARE = [
...
'users.get_request.RequestMiddleware',
'users.last_visit.SetLastVisitMiddleware'
]
from Django renders an "in exception" page instead of a page that can help debugging
No comments:
Post a Comment