简体   繁体   English

__init __()为关键字参数'input_formats'获得了多个值

[英]__init__() got multiple values for keyword argument 'input_formats'

forms.py forms.py

from django import forms

ACCEPTED_FORMATS = ['%d-%m-%Y', '%d.%m.%Y', '%d/%m/%Y']

class LeaveRequestForm(forms.Form):
    start_date = forms.DateField(input_formats=ACCEPTED_FORMATS)
    end_date = forms.DateField(input_formats=ACCEPTED_FORMATS)
    working_days = forms.IntegerField(min_value=1)

I couldn't find any date format that could pass form validation, every time I received 'Enter a valid date.', so when I tried to define some the exception came out: 每当我收到“输入有效日期”时,我都找不到任何可以通过表单验证的日期格式,因此,当我尝试定义一些日期格式时,出现了异常:

__init__() got multiple values for keyword argument 'input_formats'

https://docs.djangoproject.com/en/1.8/ref/forms/fields/#datefield https://docs.djangoproject.com/en/1.8/ref/forms/fields/#datefield

settings.py settings.py

... ...

USE_I18N = True

USE_L10N = True

... ...

I also tried built-in SelectDateWidget with no luck, every time produced invalid date. 我还尝试了内置的SelectDateWidget,但每次运出无效的日期时都没有运气。 Maybe there is some "cache" issue: "Enter a valid date" Error in Django Forms DateField 也许存在一些“缓存”问题: Django Forms DateField中的“输入有效日期”错误

What should I do to get past this validation checks and move on with proper dates? 我应该怎么做才能通过此验证检查并继续正确的日期? Are the docs missing something with an error I encountered? 文档是否缺少我遇到的错误?

input_formats is not a kwarg, it's the sole option to DateField. input_formats不是垃圾,它是DateField的唯一选项。 Drop the input_formats= 删除input_formats=

ACCEPTED_FORMATS = ['%d-%m-%Y', '%d.%m.%Y', '%d/%m/%Y']

class LeaveRequestForm(forms.Form):
    start_date = forms.DateField(ACCEPTED_FORMATS)
    end_date = forms.DateField(ACCEPTED_FORMATS)
    working_days = forms.IntegerField(min_value=1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:__ init __()得到关键字参数'customer'的多个值 - TypeError: __init__() got multiple values for keyword argument 'customer' __init__() 为关键字参数“列”获得了多个值 - __init__() got multiple values for keyword argument 'columns' TypeError:__init __()为关键字参数“ choices”获得了多个值 - TypeError: __init__() got multiple values for keyword argument 'choices' windrose:__init __()获得了多个关键字参数值 - windrose: __init__() got multiple values for keyword argument TypeError:“ __ init __()为关键字参数'name'获得了多个值” - TypeError: “__init__() got multiple values for keyword argument 'name'” __init __()为关键字参数“ bar”获得了多个值 - __init__() got multiple values for keyword argument 'bar' __init__() 为参数“填充”获得了多个值 - __init__() got multiple values for argument 'padding' __init__() 为参数“crescator”获得了多个值 - __init__() got multiple values for argument 'crescator' / __init __()的Django Rest Framework TypeError为关键字参数'read_only'获取了多个值 - Django Rest Framework TypeError at / __init__() got multiple values for keyword argument 'read_only' 在Scrapy中使用规则和请求会引发异常TypeError:__init __()为关键字参数'callback'获得了多个值 - Using Rules and Requests in Scrapy throws exception TypeError: __init__() got multiple values for keyword argument 'callback'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM