Django-jet: override list_filter filter.html support multi select not working?

Created on 22 Dec 2017  路  8Comments  路  Source: geex-arts/django-jet

/django/contrib/admin/templates/admin/filter.html

{% load i18n %}
<h3>{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}</h3>
<ul multiple>
{% for choice in choices %}
    <li{% if choice.selected %} class="selected"{% endif %}>
    <a href="{{ choice.query_string|iriencode }}">{{ choice.display }}</a></li>
{% endfor %}
</ul>

list_filter add multiple it seem only change one item, not multiple. or any idea can help it?

All 8 comments

Can you put here a traceback?

when i choose one item will immediate search, no chance choose multi.

any traceback in the console?

no error, i choose another method.

which one?

use jquery + apis replace django multi choices, it is hard to express in django.

@mapleflow can you explain in detail about the approach you used?

I know that django-jet is not maintained any longer but this is the approach I use to have multiple choice filtering in the jet admin: https://github.com/pierreben/django-jet/commit/3e376a5b9df549d4bf4b6fa609a4120681e657a5.

To use it, you have to create a custom filter in your modeladmin inheriting from MultipleChoiceListFilter:

from jet.filters import MultipleChoiceListFilter

class RegionsListFilter(MultipleChoiceListFilter):
    title = "R茅gion"
    parameter_name = "regions__in"

    def lookups(self, request, model_admin):
        return FRENCH_REGIONS_CHOICES

If some people are interested, I can submit a pr for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevin-miles picture kevin-miles  路  5Comments

VincentVW picture VincentVW  路  5Comments

PaoloC68 picture PaoloC68  路  7Comments

annamalaissh picture annamalaissh  路  5Comments

RamizSami picture RamizSami  路  4Comments