mirror of
https://github.com/jfmcbrayer/brutaldon
synced 2025-01-03 02:49:09 +01:00
13 lines
360 B
Python
13 lines
360 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()
|