user122434 user122434 - 1 year ago 104
Python Question

Get object with specific hour in django

I have model like this:

class Order(models.Model):
dateTime = models.DateTimeField()

and I want to get object with specific hour
how can I do that?
the code below doesn't work:


and has this problem:
keyword can't be an expression

now.. How should I give the order object with specific time?

Answer Source

o = Order.objects.filter(dateTime__hour=12)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download