Reputation: 1110
I need to get user timezones in order to convert a naive datetime to local time. However it's for an admin view, so it looks like I'm pretty much stuck fitting this into the model. request.session.get('django_timezone') is not available in the model, so how can you detect the timezone?
Upvotes: 0
Views: 212
Reputation: 154454
You should store the user's timezone on their profile, then access it with:
tz = some_user.get_profile().timezone
For more about Django user profiles, see: https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
Upvotes: 2