2
0
mirror of https://github.com/jfmcbrayer/brutaldon synced 2025-01-08 05:13:12 +01:00
brutaldon-interfaccia-web-m.../brutaldon/middleware/timezone.py
2019-05-17 13:07:11 -04:00

14 lines
361 B
Python

import pytz
from django.utils import timezone
from django.utils.deprecation import MiddlewareMixin
class TimezoneMiddleware(MiddlewareMixin):
def process_request(self, request):
tzname = request.session.get("timezone", "UTC")
if tzname:
timezone.activate(pytz.timezone(tzname))
else:
timezone.deactivate()