How to get SelectDateWidget in Django to show different Year options

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

Just a simple implementation gives a drop-down menu for the Year starting in 2011. I would prefer that my users are not newborns. How to change this?

+3
source share
1 answer

You can pass an argument yearswith years in any order. for instance

SelectDateWidget(years=range(1950, 2012))
+10
source

All Articles