[Django] #25845: False timezone offset warnings in admin if a custom base template doesn't set data-admin-utc-offset

44 views
Skip to first unread message

Django

unread,
Dec 2, 2015, 4:27:54 AM12/2/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+--------------------
Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Django 1.9 introduced a new data attribute on the body tag in the Django
admin base template:
https://github.com/django/django/commit/8eeb566aca33600d272dee5fba59c3445b5b8163

This attribute is read in JavaScript with getAttribute() and checked on
!== undefined to determine if it is set:
https://github.com/django/django/commit/8eeb566aca33600d272dee5fba59c3445b5b8163
#diff-cb2d960617da7bad9ba5ed3366931159R22

This worked with the previous code, but getAttribute() returns null or "",
which never equals undefined. Because of this the following code will run,
calculating false offsets between browser time and server time, causing
false warnings to appear in the admin date widgets.

More info on getAttribute():
https://developer.mozilla.org/de/docs/Web/API/Element/getAttribute#Notes

I noticed this after upgrading to Django 1.9 while using django-suit,
which is missing the attribute on body at the moment:
https://github.com/darklow/django-suit/issues/449

--
Ticket URL: <https://code.djangoproject.com/ticket/25845>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 2, 2015, 9:24:39 AM12/2/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+--------------------------------------

Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Yes, this is documented as a backwards incompatible change in the release
notes. I think django-suit needs to add support for Django 1.9 by adding
the missing body attribute unless someone has an alternate suggestion.

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:1>

Django

unread,
Dec 2, 2015, 9:38:04 AM12/2/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+--------------------------------------

Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Strayer):

But wasn't the old behavior to not show the warnings if the JavaScript
attribute is missing? As far as I can see, django-suit also didn't set the
window property !__admin_utc_offset!__ before. The warnings were not
shown, since the JS function addTimezoneWarning() won't do anything if
timezoneOffset is not set. The whole check on undefined doesn't make sense
to me and looks like a leftover of the previous code.

If the checks were to be replaced by a check on null (and possibly ""), it
would behave like before.

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:2>

Django

unread,
Dec 2, 2015, 9:51:34 AM12/2/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------

Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

Thanks for clarifying -- thank makes sense. Care to submit a patch?

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:3>

Django

unread,
Dec 4, 2015, 8:18:31 AM12/4/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------

Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by emre):

PR provided on github:
https://github.com/django/django/pull/5769

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:4>

Django

unread,
Dec 5, 2015, 4:54:28 AM12/5/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------

Reporter: Strayer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Strayer):

I already have the bug itself fixed, but I also want to add tests for
this, as suggested. Since I have some trouble getting the Django tests to
run I will hopefully be able to provide a PR with the fix and tests
tomorrow.

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:5>

Django

unread,
Dec 5, 2015, 4:55:16 AM12/5/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------
Reporter: Strayer | Owner: Strayer
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Strayer):

* owner: nobody => Strayer
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:6>

Django

unread,
Dec 7, 2015, 4:26:47 AM12/7/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------
Reporter: Strayer | Owner: Strayer
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Strayer):

Sorry it took so long... had to figure out how the Selenium tests are done
in Django.

PR is open on Github:
https://github.com/django/django/pull/5782

I also signed and submitted the CLA just now.

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:7>

Django

unread,
Dec 17, 2015, 2:35:47 PM12/17/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------
Reporter: Strayer | Owner: Strayer
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9af40f5df13801ffadcc5ded7440e4616123959f" 9af40f5d]:
{{{
#!CommitTicketReference repository=""
revision="9af40f5df13801ffadcc5ded7440e4616123959f"
Fixed #25845 -- Fixed incorrect timezone warnings in custom admin
templates.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:8>

Django

unread,
Dec 17, 2015, 2:47:53 PM12/17/15
to django-...@googlegroups.com
#25845: False timezone offset warnings in admin if a custom base template doesn't
set data-admin-utc-offset
-------------------------------+------------------------------------
Reporter: Strayer | Owner: Strayer
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"badeb56f833138fe637607fe3c7e4bfae3048e50" badeb56]:
{{{
#!CommitTicketReference repository=""
revision="badeb56f833138fe637607fe3c7e4bfae3048e50"
[1.9.x] Fixed #25845 -- Fixed incorrect timezone warnings in custom admin
templates.

Backport of 9af40f5df13801ffadcc5ded7440e4616123959f from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25845#comment:9>

Reply all
Reply to author
Forward
0 new messages