Lookup hour on DateTimeField Django -


I have a model

  class items (models.model): inicio = model < / Code>  

When I try to query this:

  itens = Item.objects.filter (inicio__hour__gte = 6)   

This gives me:

FieldError unsupported lookup 'hour' is not allowed for DateTimeField or joining in that area.

How can I query this?

You need to filter using timeliness:

  Date time to import from time to time, timeliness five_houri_gue = date time.Now () - timeliness (hours = 5) item = item.Object. FILTER (inicio__lt = five_hours_ago)   

You can always specify an exact date time and then decrease it for 5 hours if you do not want 5 hours from the current datetime.

According to my best knowledge, and accordingly, you can do an exact search for only one hour, minute or second.

Comments