Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 589
ApPeL Avatar asked Oct 14 '25 03:10

ApPeL


1 Answers

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

like image 86
sillygwailo Avatar answered Oct 17 '25 21:10

sillygwailo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!