[Answer]-Django admin redirect in SimpleListFilter

1👍

Short answer: No. The queryset method should return a filtered queryset, not a http response.

If you really want to add a link in the filter sidebar, you can hack it like this:

class ListFilter(SimpleListFilter):
    title = "test"
    template = 'admin_sidebar_links.html'

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

    def queryset(self, request, queryset):
        return queryset

Then create an html file in your templates directory called ‘admin_sidebar_links.html’, containing something along these lines:

<h3>Filter Title</h3>
<ul>
    <li><a href="/admin/test/3test/">Link</a></li>
</ul>
👤Greg

Leave a comment