django-tz-detect
django-tz-detect copied to clipboard
Timezone awareness on first view
According to the readme:
Django's timezone awareness will not be available on the first page view
Is there a specific reason this library does not attempt this?
Where we're using this library, we're getting a specific issue where when we show the site in an iFrame, it will never show the correct time zone, because of aggressive browser policies against storing cookies.
A workaround would be to add a new filter for templates that allows javascript to replace every time-zone aware field with the local time-zone equivalent, for the first view.
Or else the middleware could return a javascript redirection page to self that sets the timezone:
- The user requests the first page, "index"
- The middleware looks in the session if the timezone is present
- If it is, the first page is timezone aware
- If it's not, it replaces the page with a redirect that initially sets the timezone and then returns the right page but timezone aware