Django TimeField Model without seconds

2020-06-03 09:04发布

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 about how to manage this with Django.

Cheers

7条回答
时光不老,我们不散
2楼-- · 2020-06-03 09:34

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'))
查看更多
登录 后发表回答