I use a couple of filters, which I think I first found in the code for
generic views:

from datetime import date, time, datetime
Class.objects.filter(date__gte=datetime.combine(date(int(year),int(month),int(day)),time.min)).filter(date__lte=datetime.combine(date(int(year),int(month),int(day)),time.max)).count()

Of course, I'm sure there's a cleaner way to write that--but it does
the job.

Hope that helps!
-Justin

On Sep 5, 2:47 pm, akaihola <[EMAIL PROTECTED]> wrote:
> First, look at the behavior of Python's datetime module:
>
> >>> datetime(2008,9,4)
>
> datetime.datetime(2008, 9, 4, 0, 0)
>
> Omitting the time part is just a shorthand for midnight.
>
> I don't think that comparing microsecond-accurate timestamps to date
> values would make sense at the database level anyway.
>
> I've used __range as well in the past successfully with some helper
> functions to auto-generate the boundaries from a date object.
>
> When in doubt, dumping the queries Django generates will give you some
> insight (assuming you're SQL literate):
>
> >>> Class.objects.filter(date=datetime(2008,9,4)).query.as_sql()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to