modlinltd / django-advanced-filters

Add advanced filtering abilities to Django admin
https://pypi.org/project/django-advanced-filters/
MIT License
775 stars 173 forks source link

Only one filter shows field_choices #184

Open JuanPabloMF opened 1 year ago

JuanPabloMF commented 1 year ago

Describe the bug Screenshot from 2023-08-28 15-00-34

Currently when I add more than one filter (for example to search "Candidates" that know "python" and "Ruby on Rails") only the first filter shows field_choices.

If I change the field option to "or" and then move it back to "tech" then the field will change after a few seconds, and convert from text box to dropdown with the field_choices.

When I add a new filter, the dropdown from every filter except the first will convert to text box (but without losing the value I choose), again going back to only having a dropdown with choices in the first filter.

To Reproduce

@admin.register(Candidate)
class CandidateAdmin(AdminAdvancedFiltersMixin, admin.ModelAdmin):
    inlines = [
        SkillInline,
        JobInline
        ]
    list_display = [
        "name",
        "family_name",
        "age",
        "country",
        "city",
        "email",
        "phone",
        "last_company",
        "working",
        "salary_type",
        "salary"
        ]
    search_fields = [
        "skill__tech__name__icontains"
        ]
    list_filter = [
        "country",
        "working"
        ]
    advanced_filter_fields = [
         ("skill__tech__name", "tech"),
    ]

Steps to reproduce the behavior:

  1. Go to admin
  2. Go to Candidates List view
  3. Click on Advanced Filter
  4. Start adding new filters

Expected behavior Normally every filter should have the right form (a dropdown with field_choices instead of a text box)

Details (please complete the following information):

JuanPabloMF commented 1 year ago

I forgot to mention also I'm using Django Grappelli 3.0.7

asfaltboy commented 1 year ago

Hey Juan, it's been a while since I touched this package, so I am getting a bit less confident with the code base.

Can you try out the branch ps/frontend-fixes locally? I think this means to fix a number of frontend issues, and possibly this is one of them