Skip to main content

Easy timezones for Django (>=1.11) based on MaxMind GeoIP2.

Project description

Timezones. Yuck.

django-easy-timezones-redux Build Status

Easy IP-based timezones for Django (>=1.11) based on MaxMind GeoIP, with IPv6 support. Updated fork of django-easy-timezones that uses the new version of MaxMind's GeoIP2 database.

Quick start

  1. Install django-easy-timezones-redux

    pip install django-easy-timezones-redux
    
  2. Add "easy-timezones" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
      ...
      'easy_timezones',
    )
    
  3. Add EasyTimezoneMiddleware to your MIDDLEWARE

    MIDDLEWARE = (
      ...
      'easy_timezones.middleware.EasyTimezoneMiddleware',
    )
    
  4. Add a path to the MaxMind GeoLite2 cities databases in your settings file:

    GEOIP2_DATABASE = '/path/to/your/geoip/database/GeoLite2-City.mmdb'
    
  5. Enable localtime in your templates.

    {% load tz %}
        The UTC time is {{ object.date }}
    {% localtime on %}
        The local time is {{ object.date }}
    {% endlocaltime %}
    
  6. That's it!

Signals

You can also use signals to perform actions based on the timezone detection.

  1. To hook into the Timezone detection event to, say, save it to the request's user somewhere more permanent than a session, do something like this:

    from easy_timezones.signals import detected_timezone	
    
    @receiver(detected_timezone, sender=MyUserModel)
    def process_timezone(sender, instance, timezone, **kwargs):
    	if instance.timezone != timezone:
        	instance.timezone = timezone
        	instance.save()
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-easy-timezones-redux-1.0.4.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_easy_timezones_redux-1.0.4-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file django-easy-timezones-redux-1.0.4.tar.gz.

File metadata

  • Download URL: django-easy-timezones-redux-1.0.4.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for django-easy-timezones-redux-1.0.4.tar.gz
Algorithm Hash digest
SHA256 795c40239b4a260138b6eb3c2b0e3d62fc265f092ab18095b1eef490e7d1850d
MD5 9c54dd2a3634a638a4c2747a646dd257
BLAKE2b-256 09fb2105bbd484b89104578d5cb066cd606a022ff23bdc2b8054ae8dbec92946

See more details on using hashes here.

File details

Details for the file django_easy_timezones_redux-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: django_easy_timezones_redux-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for django_easy_timezones_redux-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d44d2ef1ce578fac14eba561dd1771788da7a376e361df241c0a01eae78b4f4b
MD5 82d43451f1e1d8c9f86e10fa9cac2936
BLAKE2b-256 98eb2ad0392c5ceaaaeb9322d232ba5044f92414d00e949157e2816427c96f38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page