On 15 janv. 2012, at 10:10, Danny W. Adair wrote:
> Is there a hook that allows the "current" timezone to be set for
> admin, so that it uses it for datetime display/submission? Maybe a
> middleware that expects a session variable configured/named in
> settings?
Currently, there's no built-in UI for timezone selection. However, I've described some ideas, along with sample code, in the documentation:
https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#selecting-the-current-time-zone
There's also a sample app here: https://bitbucket.org/aaugustin/django-tz-demo
> With full timezone support I also think it may be worth adding
> timezone to the standard User model, with a default None that falls
> back to settings.TIME_ZONE (and probably another hook to override the
> default choices).
As long as Django doesn't have a schema alteration API, it's difficult to change the User model.
There's also the question of how to store timezones in the database. If we implemented this feature, we'd have to bless a timezone implementation. pytz is pretty much the standard, and it's highly recommended, but it's possible to use another implementation of tzinfo classes if you desire.
For these reasons, I think it's better to leave the field open and see what emerges. I don't want to bless an implementation of "per-user time zone selection" now, because I don't believe we can come up with a sufficiently generic one at this point. Maybe when we have more hindsight...
Best regards,
--
Aymeric Augustin.
On Sat, Jan 28, 2012 at 09:49, Aymeric Augustin
<aymeric....@polytechnique.org> wrote:
>[...]
> Currently, there's no built-in UI for timezone selection. However, I've described some ideas, along with sample code, in the documentation:
> https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#selecting-the-current-time-zone
>
> There's also a sample app here: https://bitbucket.org/aaugustin/django-tz-demo
Yeah I saw that. So that's basically the battery compartment, and
admin currently doesn't bring timezone batteries.
Would be nice if there were some optional batteries, maybe packed
separately (django.contrib) but then comes the question of storage...
>[...]
> As long as Django doesn't have a schema alteration API, it's difficult to change the User model.
>
> There's also the question of how to store timezones in the database. If we implemented this feature, we'd have to bless a timezone implementation. pytz is pretty much the standard, and it's highly recommended, but it's possible to use another implementation of tzinfo classes if you desire.
>
> For these reasons, I think it's better to leave the field open and see what emerges. I don't want to bless an implementation of "per-user time zone selection" now, because I don't believe we can come up with a sufficiently generic one at this point. Maybe when we have more hindsight...
That makes sense, thank you.
I was personally dreaming of a pytz-based optional app where each
relevant component could be replaced. Maybe a thirdparty app will
provide this and mature until it gets added.
Cheers,
Danny