I have a Django model with time field: time_from = models.TimeField()
. I currently have a web form that sends the time in hours, for example: 12, 13, 4, 5 ... etc ...
I currently have this code: time.strptime(str(int(request.POST['time_to']) / 60), "%H")
but it's throwing an error:
'time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=3, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1)' value has an invalid format. It must be in HH:MM[:ss[.uuuuuu]] format.
How do I go about saving, for example, 4 (that means 4AM) in my model?