I want to use Model.objects.filter(datetime_lte=datetime.datetime.now.date())
How exactly can I achieve this? I am using django 1.6.5. I want only records of current date. This will give all previous day’s records also
Advertisement
Answer
You can use the __range
field lookup:
start = datetime.date.today() end = start + datetime.timedelta(days=1) Model.objects.filter(datetime__range=(start, end))