Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Using geoip2 for timezone look up

The django.contrib.gis.geoip2 framework expose a high level geolocation api. I want to use it to look up the user timezone, but the queries do not return the timezone, although the maxmind documetion says that their databases include them. Am I missing something or how could this be done?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

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. :)

about 4 years ago · Santiago Trujillo Relatório

0

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
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda