Django TimeField Model without seconds

前端 未结 7 2262
青春惊慌失措
青春惊慌失措 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条回答
  •  Happy的楠姐
    2021-02-08 13:28

    So I think the proposed and accepted solution is not optimal because with:

        datetime.widget = forms.SplitDateTimeWidget(time_format=('%H:%M'))
    

    For a SplitDateTimeField in my case but for you only change it to TimeWidget.

    Hope it helps other people too.

提交回复
热议问题