#16380 closed New feature (fixed)
admin_list_filter should pass the spec to the template
Reported by: | Harro | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | bruno@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
If the admin_list_filter inclusion tag also passed the spec object to the admin/filter.html template we could write custom filterspec's that have attributes that influence the way the filterspec is displayed (in a dropdown with javascript for instance).
Right now you have to override the change_list.html, and create your own template tag to do this and then still override the admin/filter.html to actually change how it's displayed.
Attachments (1)
Change History (9)
by , 13 years ago
Attachment: | 16380.diff added |
---|
comment:1 by , 13 years ago
Easy pickings: | set |
---|---|
Has patch: | set |
comment:2 by , 13 years ago
Easy pickings: | unset |
---|---|
Needs documentation: | set |
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 13 years ago
Example admin/filter.html
{% load i18n %} <h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3> {% if spec.field.related and choices|length > 5 %} <select class="filter_choice"> {% for choice in choices %} <option value="{{ choice.query_string|iriencode }}"{% if choice.selected %} selected='selected'{% endif %}>{{ choice.display|safe }}</option> {% endfor %} </select> {% else %} <ul> {% for choice in choices %} <li{% if choice.selected %} class="selected"{% endif %}> <a href="{{ choice.query_string|iriencode }}">{{ choice.display }}</a></li> {% endfor %} </ul> {% endif %}
And this little bit of javascript somewhere on document.ready:
$(".filter_choice").change(function() { location.href = $(this).val(); });
comment:6 by , 11 years ago
Cc: | added |
---|
This ticket could be closed, admin_list_filter
is now (in v1.6 at least) a simple_tag
that uses the spec's template AND pass the spec to the template (cf https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_list.py line 409).
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Hi,
Thanks for digging up these old out-of-date tickets
FYI, you don't need special permmissions to close a ticket here and you can do so yourself.
Putting the commit id in the comment when you close a ticket will help us double check.
In this case, this issue appears to have been fixed in 4dbeb4bca4638ff851a2f4844d262dbe1652f7b5.
Thanks.
While this is an interesting idea, this needs an actual example and tests.