3π
β
It would appear that time_zone
is a field on the geoip2.records.Location
class in the MaxMind GeoIP2 API.
On the Django wrapper, the response is defined here, and does not forward the time_zone
field along.
You could add a line to the wrapper that is simply:
'time_zone': response.location.time_zone,
Iβm sure they would appreciate a pull request. π
1π
The class below over-rides the GeoIP2
class to expose timezone info. Could be useful until / if itβs added in the base class (will try to raise a PR for it soon if nobody gets to it first)
from django.contrib.gis.geoip2 import GeoIP2
class GeoipWithTimezone(GeoIP2):
def timezone(self, query):
enc_query = self._check_query(query, city=True)
return self._city.city(enc_query).location.time_zone
π€gar
- [Django]-Using UUIDField in Django keeps creating new migrations
- [Django]-Need help to render img in pdf from template using xhtml2pdf
Source:stackexchange.com