Django TimeField Model without seconds

前端 未结 7 2142
青春惊慌失措
青春惊慌失措 2021-02-08 12:48

Greetings, I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost

7条回答
  •  -上瘾入骨i
    2021-02-08 13:37

    Django widget can be used to achieve this easily.

    from django import forms
    
    class timeSlotForm(forms.Form):
        from_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
    

提交回复
热议问题