29👍
✅
I had exactly this problem in my app, and solved it by passing a format
parameter to Django’s TimeInput
widget:
from django import forms
class SettingsForm(forms.Form):
delivery_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
12👍
Assuming you have a format you want all TimeFields
to use, you can add the TIME_INPUT_FORMATS
to your settings file. For example, TIME_INPUT_FORMATS = ('%I:%M %p',)
will format your times as “5:30 PM”.
The docs: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TIME_INPUT_FORMATS
👤Josh
- You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
- How does this Man-In-The-Middle attack work?
- Improving Performance of Django ForeignKey Fields in Admin
- Sometimes request.session.session_key is None
Source:stackexchange.com