@@ -0,0 +1,1410 @@
+import requests%0A%0A%0Aclass IPUserInfo:%0A    user_info = None%0A    _ip = None%0A%0A    def __init__(self, request):%0A        self.request = request%0A%0A    @property%0A    def ip(self):%0A        if self._ip is None:%0A            x_forwarded_for = self.request.META.get('HTTP_X_FORWARDED_FOR')%0A            if x_forwarded_for:%0A                self._ip = x_forwarded_for.split(',')%5B0%5D%0A            else:%0A                self._ip = self.request.META.get('REMOTE_ADDR')%0A        return self._ip%0A%0A    def _get_data_from_freegeoip(self):%0A        if self.ip:%0A            url = f'https://freegeoip.net/json/%7Bself.ip%7D'%0A            try:%0A                response = requests.get(url, timeout=2)%0A            except requests.exceptions.Timeout:%0A                return %7B%7D%0A            else:%0A                if response.status_code == 200:%0A                    return response.json()%0A        return %7B%7D%0A%0A    def _get_value(self, key, default=''):%0A        if self.user_info is None:%0A            self.user_info = self._get_data_from_freegeoip()%0A        return self.user_info.get(key, default)%0A%0A    @property%0A    def timezone(self):%0A        return self._get_value('time_zone', default='')%0A%0A%0Adef get_user_timezone(request):%0A    timezone = request.COOKIES.get('timezone') or request.session.get('timezone')%0A    if timezone:%0A        return timezone%0A    timezone = IPUserInfo(request).timezone%0A    request.session%5B'timezone'%5D = timezone%0A    return timezone%0A

add utils for getting time zone using freegeoip.net