Easy timezones for Django (>=1.7) based on MaxMind GeoIP.
Project description
Timezones. Yuck.
django-easy-timezones 
Easy IP-based timezones for Django (>=1.7) based on MaxMind GeoIP, with IPv6 support.
Quick start
Install django-easy-timezones
pip install django-easy-timezonesAdd “easy-timezones” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = ( ... 'easy_timezones', )Add EasyTimezoneMiddleware to your MIDDLEWARE_CLASSES
MIDDLEWARE_CLASSES = ( ... 'easy_timezones.middleware.EasyTimezoneMiddleware', )(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'Enable localtime in your templates.
{% load tz %} The UTC time is {{ object.date }} {% localtime on %} The local time is {{ object.date }} {% endlocaltime %}Twist one up, cause you’re done, homie!
Signals
You can also use signals to perform actions based on the timezone detection.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-easy-timezones-0.8.0.tar.gz.
File metadata
- Download URL: django-easy-timezones-0.8.0.tar.gz
- Upload date:
- Size: 24.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d28a5e60263de39eeef72240dac01090a11f7212d942dfbd3b4ba4be7b2bf77e
|
|
| MD5 |
81978906eabc7fa2f1225132dcdb7a86
|
|
| BLAKE2b-256 |
3729a7704dfb1941af1c2886136153ab2bae4261a01917bdfae0d6af028161ec
|
File details
Details for the file django_easy_timezones-0.8.0-py2-none-any.whl.
File metadata
- Download URL: django_easy_timezones-0.8.0-py2-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c90f8a9731bf0762b6c7d239beb5b9434f45e8c9bbdc3586faa69851d00c434
|
|
| MD5 |
9208236318fb8a367c5eac0fb9307861
|
|
| BLAKE2b-256 |
c7a19aefa75fa468a986b7151d754d9f276eb43f088573a6a55962487cf565dc
|