ApPeL
ApPeL

Reputation: 4911

django SelectDateWidget Years in reverse

Is there a way in which you can get the "SelectDateWidget" to display the years in reverse or DESC order?

my_form_field = forms.DateField(widget=MonthYearWidget(years=range(2012,1970)))

Does not seem to work.

MonthYear widget is a smaller breakdown that only gives you the month and year

Upvotes: 3

Views: 1808

Answers (1)

sillygwailo
sillygwailo

Reputation: 2007

Try years=range(2012,1970,-1) (note the -1 as the step/increment).

Upvotes: 6

Related Questions