简体   繁体   English

迄今为止的Django过滤器

[英]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 我正在尝试找到一种使用开始日期和结束日期在Django Admin上为日期设置过滤器的方法,但是在docs上,搜索似乎像这样执行SQL搜索

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 https://docs.djangoproject.com/en/1.7/ref/models/querysets/#range

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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