darklow / django-suit

Modern theme for Django admin interface
http://djangosuit.com/
Other
2.32k stars 704 forks source link

Custom filters do not appear in horizontal row #679

Closed gamesbook closed 6 years ago

gamesbook commented 6 years ago

Django version: 1.11.12 Django Suit version: 2.0a1 Python version: 3.4.3

Issue:

In the admin, given that I have:

    list_filter = (filters.ActivityBySiteFilter, filters.SiteActivityListFilter,
                   'planned_date', 'completed_date', 'responsible',
                   'date_change', 'edited_by', 'actual_date',)
    suit_list_filter_horizontal = (
        filters.ActivityBySiteFilter, filters.SiteActivityListFilter,
        'planned_date', 'completed_date', 'responsible',
        'date_change', 'edited_by', 'actual_date',)

All the normal filters ('name') appear across the top in a single row; but the two custom filters do not.

Please can suit be updated to display these as expected?

shulcsm commented 6 years ago

suit_list_filter_horizontal is expecting string value of "filter_id" see here: https://github.com/darklow/django-suit/blob/v2/suit/templatetags/suit_list.py#L216 Current implementation is very naive but i don't see any obvious solutions since ListFilter doesn't implement string id.

P.S.: If you want to make all your filters horizontal you can do suit_list_filter_horizontal = '__all__'

jayWarr commented 6 years ago

I have the identical problem to gamesbook with the similarbehaviour. I tried the solution: suit_list_filter_horizontal = '__all__' All my horizontal filters disappeared and were replaced by a vertical 1st-in-the-list filter ?!

shulcsm commented 6 years ago

@jayWarr are you sure you are on latest version? There is no tag yet

jayWarr commented 6 years ago

I'm using: Python 3.6.3 Django 2.0.4 Suit 2.0a1

gamesbook commented 6 years ago

@jayWarr "All my horizontal filters disappeared and were replaced by a vertical 1st-in-the-list filter" Yes, I have the same outcome. suit_list_filter_horizontal = '__all__' does not work.

gamesbook commented 6 years ago

I have uninstalled and re-installed and now the changes are through.

It would be ideal if the tag was updated though....

darklow commented 6 years ago

Hmm, why not use it like this:


list_filter = (filters.ActivityBySiteFilter, ...)
suit_list_filter_horizontal = list_filter
gamesbook commented 6 years ago

@darklow Its not always a 1:1 mix. But I have since found you can refer to a SimpleListFilter by its parameter name.