django-suit icon indicating copy to clipboard operation
django-suit copied to clipboard

Django 1.9 requires a "data-admin-utc-offset" attribute on body for timezone checks

Open strayer opened this issue 10 years ago • 1 comments

Django 1.9 introduced a new attribute on the body tag for checking timezone differences: https://github.com/django/django/commit/8eeb566aca33600d272dee5fba59c3445b5b8163

There seems to be an issue in the Django code, because getAttribute returns null if the attribute doesn't exist, causing false timezone warnings to appear if the admin template doesn't set the attribute in the body tag - this is how I noticed the change.

This is the missing tag: https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/base.html#L15

strayer avatar Dec 02 '15 08:12 strayer

temporary hacked for me by overriding template admin/change_form.html with next code:

{% extends "admin/change_form.html" %}

{% block extrahead %}
    <script type="application/javascript">
        (function($){
            $(function(){
                document.body.setAttribute("data-admin-utc-offset","{% now "Z" %}");
            })
        })(jQuery)
    </script>
    {{ block.super }}
{% endblock %}

but better if it will be fixed here by library)

Lagovas avatar Jan 11 '19 13:01 Lagovas