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.
In django 1.4, you can user list_filter. try:
from django.contrib.admin import DateFieldListFilter class PersonAdmin(ModelAdmin): list_filter = ( ('date_field_name', DateFieldListFilter), )
This will give some built-in ranges, but it will work if you put the date range in url, like:
?date__gte=2009-5-1&date__lt=2009-8-1
If you need a date picker (like jquery), then you need to extend DateFieldListFilter. I sent a patch to django-admin-filtrate, so, check there soon.
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