9👍
✅
By default the TimeInput widget renders as an html input field of type text:
<input type="text" name="time" id="id_time">
If, instead, you want to render it as an html input field of type time:
<input type="time" name="time" id="id_time">
then in the meta widgets section of your ModelForm class add a type attribute like this:
'time': forms.TimeInput(attrs={'type': 'time'})
👤User
0👍
I had the same problem with TimeInput().
I ended up following Vitor Freitas’ tutorial and using Django Tempus Dominus, which includes a Time Picker option.
Hope this helps!
- [Django]-How to update a single field in a model using UpdateAPIView from Djangorestframework?
- [Django]-Django CreateView : Append ForeignKey to CustomForm Data
- [Django]-How to pass special characters in the urls in django
- [Django]-Django: how to get the current user's group id
Source:stackexchange.com