I am a newbie with Django and have a model with a DateTime field which is shown in the django admin.
In the list_filter option when I specify the fieldname I get the basic Django filter interface for date fields with 4 links (today, this month, past 7 days, etc.)
I now want to add a "next 7 days" option. This will require a minor tweak by extending the DateFieldListFilter class. However, Django throws the system check (admin.E114) The value of 'list_filter[0]' must not inherit from 'FieldListFilter'. when I try to extend it.
The only way it seems possible after a bit of search is by extending the SimpleListFilter class but it seems like a lot of work for such a small thing. (since I will have to duplicate functionality already taken care of in DateFieldListFilter)
Is there a simpler way of achieving this?
Assume we have a model called
Book
with apublished_at
field which is aDateTimeField
. You could then achieve this type of filtering by doing something like this (code is based on DateFieldListFilter as seen in https://github.com/django/django/blob/4ad2f862844d35404e4798b3227517625210a72e/django/contrib/admin/filters.py):