Today I submitted a package to PyPi called django-datetime-utc
. You
can install it via Pip:
$ pip install django-datetime-utc
This package provides DateTimeUTCField
, a naive datetime model field. In
PostgreSQL this translates to the field timestamp without time zone. All
timestamps are saved in UTC.
I created this because the problem with using Django's DateTimeField
is
unless the default time zone on your (PostgreSQL) database server is set to UTC
it doesn't matter which TZ settings you select in Django, PostgreSQL will save
all timestamps in local time with an offset.
This new field:
- Supports the default
DateTimeField
options such asauto_now_add
andauto_now
- Works with South
- Saves all timestamps in UTC
- Values automatically converted to local time (specified by
TIME_ZONE
in your project settings.py) in forms and templates
To find out more head over to the project pages on GitHub and PyPi where the latest installation and usage instructions can be found.