import pytz

from django.conf import settings
from django.utils import timezone


class TimeZoneMiddleware:
    def process_request(self, request):
        tz = settings.TIME_ZONES.get(request.LANGUAGE_CODE, settings.TIME_ZONE)
        timezone.activate(pytz.timezone(tz))
