How can make custom filter in django admin. I mean write a method do some calculation in it and add it to list_filter.
For Django 1.4-1.7, list_filter allows you to use a subclass of SimpleListFilter . It should be possible to create a simple list filter that lists the values you want.
The filter() method is used to filter you search, and allows you to return only the rows that matches the search term.
Nope. Django filters operate at the database level, generating SQL. To filter based on Python properties, you have to load the object into Python to evaluate the property--and at that point, you've already done all the work to load it.
You can use a class inheriting from django.contrib.admin.SimpleListFilter like as described at here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With