[Django]-Formatting TimeField

4👍

The Django admin uses the AdminTimeWidget instead of forms.TimeInput. Try changing your code to the following:

from django.contrib.admin.widgets import AdminTimeWidget

class myTimeForm(forms.ModelForm):
    start_time = forms.TimeField(widget=AdminTimeWidget(format='%H:%M'))
    class Meta:
        model = MyModel

Leave a comment