farhan0581 / django-admin-autocomplete-filter

A simple Django app to render list filters in django admin using autocomplete widget.
GNU General Public License v3.0
351 stars 76 forks source link

Custom search viewset doesn't work in Django >= 3.2 #83

Open KaktusOnFire opened 2 years ago

KaktusOnFire commented 2 years ago

When i try to create custom view as its documented in README, i gets following error:

AttributeError: 'CustomSearchView' object has no attribute 'source_field'

and the search field shows nothing

edcohen08 commented 2 years ago

I got around this by adding source_field as an attribute on my CustomSearchView, and I just passed the name of the fk field. I added that to as_view call so that looks like CustomSearchView.as_view(model_admin=self, source_field='fk_field')

That almost worked and the last change was just that rather than ever using super.get_queryset() I wrote custom logic for filtering the get_queryset method