Filter change list by a date range
The Django admin site has a feature to filter objects in change list by parameters supplied in the query string. Particularly, parameters such as date\__gte and date\__lte can be used. This example is for filtering objects in change list by a date range (the date field is called expiration_date, but you can, of course, use any other name). As the server side (Django) already supports such filtering, all you need to do is to edit this for your needs (you can also add some DRY if you want) and put it into templates/admin/app_name/model_name/change_list.html. Some CSS for better layout: div.date_filter select#from_month, div.date_filter select#to_month { margin-left: 0; } div.date_filter label { margin-right: 5px; }
- javascript
- date
- jquery
- html
- change_list
- change-list
- date-range