> Any idea on what is going on here? I'm particularly perplexed as to
> why the admin page and my view are giving different times.
>
That does sound weird.
What database are you using?
Not an immediate help, but the sane way to handle timezones in django in
my experience:
(0) don't use windows on the server, if you are, set the system clock to
utc and live with it.
(1) preferably be using postgresql (good timezone handling)
(2) set django settings TIME_ZONE = 'UTC' and work in utc internally.
django will [try to, bearing in mind Graham's post] set TZ - and will
also tell postgresql to expect and return times in utc over the wire
(explicitly executes a "SET TIME ZONE" command in the connection).
django models.DateTimeFields become "timestamp with time zone"
postgresql fields, so your database now uses UTC timestamps that say
they are UTC and everything just works. Only now everything's in UTC...
so...
(3) use django-timezones (django helpers around pytz) to localize
user-facing time and accept local time inputs
http://github.com/brosner/django-timezones/
Even though my apps only really operate in one timezone, it's a $%^Łing
DST timezone (as is America/New_York), so the above is a real win.
Of course, you may be stuck dealing with a legacy db with non-utc
time.
That does sound weird.
BEC wrote:
> Any idea on what is going on here? I'm particularly perplexed as to
> why the admin page and my view are giving different times.
>
What database are you using?
Not an immediate help, but the sane way to handle timezones in django in
my experience:
(0) don't use windows on the server, if you are, set the system clock to
utc and live with it.
(1) preferably be using postgresql (good timezone handling)
(2) set django settings TIME_ZONE = 'UTC' and work in utc internally.
django will [try to, bearing in mind Graham's post] set TZ - and will
also tell postgresql to expect and return times in utc over the wire
(explicitly executes a "SET TIME ZONE" command in the connection).
django models.DateTimeFields become "timestamp with time zone"
postgresql fields, so your database now uses UTC timestamps that say
they are UTC and everything just works. Only now everything's in UTC...
so...
(3) use django-timezones (django helpers around pytz) to localize
user-facing time and accept local time inputs
http://github.com/brosner/django-timezones/
Even though my apps only really operate in one timezone, it's a $%^£ing