On 09/04/10 19:05, Paweł Roman wrote:
I've noticed that django always fetches 'naive' datetimes from the
database. Tzinfo property on a datetime object is always set to null,
even if the database stores a value WITH a timezone.

This is a bit tedious because such datetime cannot be later converted
to any timezone. Each time I want to display a datetime on the screen
(converted to user's time zone) I have to copy it applying UTC as a
tzinfo (this is how it is stored in the database) and then convert to
relevant timezone with astimezone(). OK, that's one line of code :)
but I have a feeling that this line should be somewhere inside in the
django code.



I recommend using django settings.TIME_ZONE = 'UTC', then use:

http://github.com/brosner/django-timezones

to localize time for presentation.

N.B. Among other things it has a
LocalizedDateTimeField for use on models. If you use it and tell
it UTC, you should get a non-naive pytz UTC datetime.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to