You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a sorting_filters tuple to filter subsets of objects. This was working fine previously, and I suspect it stopped working when I upgraded to Django 4 (though I haven't fully checked that).
The error I see is
Cannot resolve keyword 'sort_filter' into field.
And debug shows
filters {'sort_filter': '0'} request <WSGIRequest: GET '/admin/gallery/slide/?sort_filter=0'>
at line 60 in changelist_view of django-admin-sortable/adminsortable/admin.py.
It looks to me like the sort_filter in the querystring should not be parsed into filters. This is done in the get_querystring_filters method which already ignores keys IGNORED_PARAMS and PAGE_VAR. By also ignoring sort_filter and e (which can also get in there). My code is working again.
I hope this is useful and allows someone to spot the correct quick fix.
The text was updated successfully, but these errors were encountered:
And just in case anyone needs a quick workaround, for me it works to override get_querystring_filters in my admin class:
class SlideAdmin(SortableAdmin):
list_display = ('headline', 'strapline', 'link', )
def get_querystring_filters(self, request):
filters = super().get_querystring_filters(request)
return {k: v for k, v in filters.items() if k != 'sort_filter' and k != 'e'}
I am using a sorting_filters tuple to filter subsets of objects. This was working fine previously, and I suspect it stopped working when I upgraded to Django 4 (though I haven't fully checked that).
The error I see is
Cannot resolve keyword 'sort_filter' into field.
And debug shows
filters {'sort_filter': '0'}
request <WSGIRequest: GET '/admin/gallery/slide/?sort_filter=0'>
at line 60 in
changelist_view
of django-admin-sortable/adminsortable/admin.py.It looks to me like the
sort_filter
in the querystring should not be parsed intofilters
. This is done in theget_querystring_filters
method which already ignores keysIGNORED_PARAMS
andPAGE_VAR
. By also ignoringsort_filter
ande
(which can also get in there). My code is working again.I hope this is useful and allows someone to spot the correct quick fix.
The text was updated successfully, but these errors were encountered: