silentsokolov / django-admin-rangefilter

A Django app that lets you filter data by date range and numeric range in the admin UI
MIT License
721 stars 106 forks source link

django 1.10.5 Grappelli some app lost datepicker button #12

Closed mapleflow closed 7 years ago

mapleflow commented 7 years ago

missing

The html button missing class="ui-datepicker-trigger" when list_editable missing

the browser console no errors or warnings.

my env: python 3.4, django 1.10.5, theme Grappelli, is env cause error?

silentsokolov commented 7 years ago

Grappelli not support

mapleflow commented 7 years ago

thanks for your replay.

it works when add list_editable field.

jrobichaud commented 8 months ago

@mapleflow the reason why having any field list_editable makes the date pickers to suddently work is because grappelli will execute some javascript to initialize the date time pickers where there are forms.

You can create a custom template to make sure the date pickers are initialized in change lists

<project dir>/templates/admin/change_list.html

{% extends "admin/change_list.html" %}
{% load i18n %}

{% block javascripts %}
{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:'../../../jsi18n/' }}"></script>
<script type="text/javascript" charset="utf-8">
    (function($) {
        $(document).ready(function() {
            grappelli.
            initDateAndTimePicker();
        });
    })(grp.jQuery);
</script>
{% endblock %}