Sussagittikasusa
Sussagittikasusa

Reputation: 2581

How to get SelectDateWidget in Django to show different "Year" options

class PersonalForm(ModelForm):
    class Meta:
        model = InfoPersonal
        widgets = {'dateofbirth' :  SelectDateWidget()}

Just the simple implementation gives a dropdown for the Year starting from 2011. I would rather have my users not be newborn babies. How do I customize this ?

Upvotes: 3

Views: 1655

Answers (1)

DrTyrsa
DrTyrsa

Reputation: 31951

You can pass years argument wiith list of years in any order. For example

SelectDateWidget(years=range(1950, 2012))

Upvotes: 10

Related Questions