简体   繁体   中英

Django filter from date to date

I'm trying to find a way to set a filter on Django Admin for dates using start date and end date, but on the docs the search seems to do a SQL search like so

WHERE (first_name ILIKE 'john' OR last_name ILIKE 'john')
AND (first_name ILIKE 'lennon' OR last_name ILIKE 'lennon')

If you are doing date search you can use the range field look up function. https://docs.djangoproject.com/en/1.7/ref/models/querysets/#range

Eg. Employee.objects.filter(bday__range=(start_date, end_date))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM