Inviews.py
:
if request.method == "POST":
from_date = request.POST.get("from_date")
f_date = datetime.datetime.strptime(from_date,'%Y-%m-%d')
print(f_date)
to_date = request.POST.get("to_date")
t_date = datetime.datetime.strptime(to_date, '%Y-%m-%d')
print(t_date)
check_box_status = request.POST.get("new_records", None)
print(check_box_status)
drop_down_status = request.POST.get("field")
print(drop_down_status)
if check_box_status is None:
get_records_by_date = Scrapper.objects.filter(start_time__range=(f_date, t_date))
下面的代码get_records_by_date = Scrapper.objects.filter(start_time__range=(f_date, t_date))
无法包含t_date
。是否有办法包含t_date
?
Breaks.objects.filter(date__range=["2011-01-01", "2011-01-31"])
或者如果你只是想按月过滤:
Breaks.objects.filter(date__year='2011',
date__month='01')
请回复此消息,如果它不工作。