I would like to filter objects per day with datetime, but cannot find examples of how to do this anywhere.
This, for example, works just fine, pulling out all of the following events:
@login_required def invoice_picker(request): """Grab a date from the URL and show all the invoicable deliveries for that day.""" query = request.GET.get('q' , '2/9/1984') date = datetime date = datetime.strptime('7/14/2010', '%m/%d/%Y') date = date.strptime(query, '%m/%d/%Y') results = [] if query: results = LaundryDelivery.objects.filter(end__gte=date) return render_to_response('invoicer.html', { 'results' : results, 'date' : date, 'user' : request.user, })
But when I delete __gte, it does not return anything, because the dates go along the lines 2010-06-22 04:04:00 instead of 2010-06-22 00:00:00. I also tried:
results = LaundryDelivery.objects.filter(end.date=date)
but unfortunately I get the error "keyword cannot be an expression". Any ideas?
source share