2๐
โ
I would use django-filter (https://github.com/alex/django-filter) for this kind of thing. It does all the filtering for you. It just gives you a Form
which you can display.
EDIT:
For a range date filter, (start and end date) you can just add 2 filters, one with lte
lookup, and one with gte
lookup. For example:
date_start = django_filters.DateFilter(name='{date field to filter}' lookup_type='gte')
date_end = django_filters.DateFilter(name='{date field to filter}' lookup_type='lte')
๐คjproffitt
Source:stackexchange.com