Storing times in UTC in Django

I just want to store my time values in UTC, and render them in Europe/Berlin for display, as supposedly one should, and Django, in 2011 and with 1.4 looming, still does not support this (although things may be happening).

I’ve found that the simplest way to deal with this is to use a filter which can convert from UTC to the TIME_ZONE setting, and can be placed before any of Django’s time, timesince, nativetime etc. filters one may want to use.

That still leaves you with a lack of timezone support in the admin, or when using model fields in general, but if you don’t care about those, this is the quickest way to make it work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s