From 1efa4389e9d6e57315441d190da324101fd0c463 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 1 Apr 2020 09:03:23 +0530 Subject: Fix custom middleware according to django 3 --- yaksh/middleware/user_time_zone.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'yaksh/middleware/user_time_zone.py') diff --git a/yaksh/middleware/user_time_zone.py b/yaksh/middleware/user_time_zone.py index 92035e8..8140851 100644 --- a/yaksh/middleware/user_time_zone.py +++ b/yaksh/middleware/user_time_zone.py @@ -12,12 +12,17 @@ class TimezoneMiddleware(object): self.get_response = get_response def __call__(self, request): - return self.get_response(request) - - def process_request(self, request): + # Code to be executed for each request before + # the view (and later middleware) are called. user = request.user user_tz = 'Asia/Kolkata' if hasattr(user, 'profile'): if user.profile.timezone: user_tz = user.profile.timezone timezone.activate(pytz.timezone(user_tz)) + + response = self.get_response(request) + + # Code to be executed for each request/response after + # the view is called. + return response -- cgit