Can Django admin site select entries by a custom date range, i.e. using two DateFields with AdminDateWidget? I know that there are date_hierarchy and list_filter properties, but they don’t seem very useful when there are a lot of DB entries and you just need to filter items by exact date__gte and date__lte query.
Can Django admin site select entries by a custom date range, i.e. using two
Share
Note: I wrote this answer in 2009, when the required functionality was not available in Django as a public API. For Django 1.4+, see the other answers.
This functionality isn’t provided as far as I’m aware, but you can build it yourself.
Firstly, you can filter items using
date__gteanddate__lteas GET arguments in the url.For example
will display all bar objects with dates in May, June or July 2009.
Then if you override the admin/change_list.html template file, you can add widgets for start and end dates, which navigate to the required url.
Hat tip to Daniel’s answer to another SO question, which taught me about using queryset filter parameters as GET arguments.