输入时间与自定义表格麻烦

时间:2019-03-23 13:30:52

标签: django python-3.x django-forms

我的自定义表单上的TimeFileld有问题

我无法从字段中删除秒,并且我的验证未在字段中看到值

我尝试在TimeInput中使用很多input_formats,在TimeField中使用格式

class OrderForm(forms.Form):
    client_name = forms.CharField(required=True)
    client_lastname = forms.CharField(required=True)
    client_patronymic = forms.CharField(required=True)
    client_phone = forms.CharField(required=True)
    master = forms.ModelChoiceField(Master.objects.all())
    client_car = forms.CharField(required=True)
    plan_date = forms.DateField(widget=forms.widgets.DateInput(attrs={'type': 'date'}))
    plan_time = forms.TimeField(input_formats=['%H:%M','%I:%M %p'],
                                widget=forms.widgets.TimeInput(attrs={'class':'time_field', 'type': 'time'},format=["%H:%M","%I:%M %p"]))


    class Meta:
        model = Order
        fields = ('client_name', 'client_lastname', 'client_patronymic', 'client_phone',
                  'plan_date', 'plan_time', 'master',  'client_car')
{% extends 'base.html' %}

{% block title %}Order{% endblock %}

{% block content %}
  <h2>Create order</h2>
  <form method="post" action="make_order">
    {% csrf_token %}
    {{ form.as_p }}
    <button type="submit">Create</button>
  </form>
{% endblock %}

我想以'HH:MM'格式输入时间,但是现在我输入时间,并且有'-'表示秒数,并且没有输入时间

0 个答案:

没有答案