Django Rest框架 - 无法在DateTimeField HTML表单上指定秒数

时间:2018-04-29 16:57:42

标签: django python-3.x django-forms django-rest-framework django-views

我正在使用Django REST框架并尝试在HTML表单上发布一个DateTimeField,我可以编写除秒之外的所有内容。

这是一个显示我的意思的打印屏幕: enter image description here

我已尝试将序列化程序更新为:

timestamp = serializers.DateTimeField(input_formats='%Y-%m-%dT%H:%M:%SZ')

但它没有用。

1 个答案:

答案 0 :(得分:0)

以下是对input formats的引用,我认为您可以让您的示例像这样工作

def __init__(self):
    wx.Frame.__init__(self, None, title="Dropdown Test", size=(400,400))
    control_sizer = wx.GridBagSizer(vgap=3, hgap=10)
    label1 = wx.StaticText(self, -1, label="First Dropdown:", size=(120,25))
    control_sizer.Add(label1, (0,0), (1,1), flag=wx.LEFT | wx.TOP | wx.EXPAND, border=10)
    label2 = wx.StaticText(self, -1, label="Second Dropdown:", size=(120,25))
    control_sizer.Add(label2, (1,0), (1,1), flag=wx.LEFT | wx.TOP | wx.EXPAND, border=10)
    self.choice1 = wx.Choice(self, -1, choices=["thing 1","thing 2","thing 3","thing 4"], size=(120,25))
    self.choice1.SetSelection(0)
    control_sizer.Add(self.choice1, (0,1), (1,1), flag=wx.RIGHT | wx.EXPAND, border=10)
    self.choice2 = wx.Choice(self, -1, choices=["stuff 1","stuff 2","stuff 3","stuff 4"], size=(120,25))
    control_sizer.Add(self.choice2, (1,1), (1,1), flag=wx.RIGHT | wx.EXPAND, border=10)
    self.choice2.SetSelection(1)
    self.SetSizerAndFit(control_sizer)