Awesome Open Source
Awesome Open Source

Timezones. Yuck.

django-easy-timezones Build Status

Easy IP-based timezones for Django (>=1.7) based on MaxMind GeoIP, with IPv6 support.

Quick start

  1. Install django-easy-timezones

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

  3. Add EasyTimezoneMiddleware to your MIDDLEWARE_CLASSES

  4. (Optionally) Add a path to the MaxMind GeoIP cities databases (direct link because I'm nice) in your settings file:

    GEOIP_DATABASE = '/path/to/your/geoip/database/GeoLiteCity.dat'
    GEOIPV6_DATABASE = '/path/to/your/geoip/database/GeoLiteCityv6.dat'
  5. Enable localtime in your templates.

    {% load tz %}
        The UTC time is {{ }}
    {% localtime on %}
        The local time is {{ }}
    {% endlocaltime %}
  6. Twist one up, cause you're done, homie!


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

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (47,717
django (916
easy-to-use (79
easy (43
timezone (36
automatic (32
geoip (29

Find Open Source By Browsing 7,000 Topics Across 59 Categories