I am trying to use the SelectDateWidget in a form, but it is telling me that the field is required. My model says that the DateField can be null and blank, and in the admin site, it doesn't have a problem with me leaving it blan开发者_运维知识库k. I am using the version of the widget from http://code.djangoproject.com/ticket/9124
Here is the code in my form:
birth_date = forms.DateField(widget=SelectDateWidget(years=range(1700, date.today().year+1), required=False))
Any ideas?
Your required=False
is in the wrong place. It is inside the call to the widget, whereas actually it is a parameter to the field. Move it outside the innermost brackets.
精彩评论