Django model TimeField views.py cannot select hour or minute

Viewed 428

When using a TimeField in a Django model I wish to be able to perform a query in a view, using the hour and minute elements of the TimeField separately.

However, when I do so, if I run the view I receive an error message that the __hour (or __minute) does not exist (see code below):

scheduleItems = DEVICESCHEDULE.objects.filter(time__hour = nowHour)

If I change the model to use a DateTimeField rather than a TimeField, I am able to use the __hour and __minute options.

I would prefer to keep the field type as a TimeField, as I only need a time to be input and inputting a date (even if it is ignored) is confusing to the user.

Thanks in advance!

1 Answers
Related