views:

462

answers:

1

No documentation on this one, should be simple, but not functioning for me.

Here's the raw code: http://code.djangoproject.com/browser/django/trunk/django/forms/extras/widgets.py

Trying to pass a value of required=False to the Widget to get blank values (line 23 in the raw code: none_value = (0, '---')) but get an unexpected argument raised with the code:

partner_date_of_birth = forms.DateField(required=False, 
   widget=forms.extras.SelectDateWidget(required=False,years=range(1940, 1992)))

Works without the second required=False argument, but doesn't have the 'Blank option in the form option list - which I'd need to be default.

Any tips on where I'm going wrong?

A: 

Sounds like you're using a slightly earlier version of Django. The code you reference in your question is from trunk... the latest and greatest version. Earlier releases of Django (for example 1.0) did not render a None value for the SelectDateWidget... see ticket 9124 SelectDateWidget not usable with required=False. You'll either need to upgrade Django, or roll your own SelectDateWidget (perhaps by copying the version from trunk into your own project tree) if you can't upgrade Django.

Jarret Hardie