Django admin filter, how to default to 'No' or 'Yes' rather than 'All'?

As the title says, I want to set the filter of a certain field to be set to ‘No’ by default, not ‘All’.
I am not sure how I can set this.

Any help would be appreicated


A filter in what? Can you provide more context about what you’re trying to do?


On django admin, you can see various filters(per field specified in list_filter) on the right side of the page.
There we have three options for Boolean field - ‘All’, ‘Yes’ and ‘No’
Default is ‘All’ and I want to change that to ‘No’
So when I go to that page, only objects with that field is set to False will be shown in the list.
Hope this makes sense


You’ll need to create your own FieldListFilter class. The docs describe how to add one generally. Though I would implement mine as a subclass of BooleanFieldListFilter, but override __init__ to set the default to the No case.


Thanks for the answer.
But I still cannot figure out which property or method I should override in BooleanFieldListFilter.
Could you please provide me more details?


Hi, Tim!

I figured it out.
I added an entry(query: value) to used_parameters dictionary on __init__method.
Like this:
self.used_parameters = {‘is_active__exact’: True}

Thanks for your hint. :smiley: