开发者

How to set MaxDate and MinDate of a SelectDateWidget in Django?

How to set MaxDate and MinDate of a SelectDateWidget in Django?

I am using that widget for a birthdate field.

#found in:
from django.forms.extras.widgets import SelectDateWidget
from django import forms

def someform(forms.Form):
    birthdate = forms.DateField(widget=SelectDateWidget())

So how do I change its MaxDate and MinDate? its default MinDate is this year and its MaxDate is 9 years after this year.

I want the MinDate to be maybe 100 years before this year and the Maxdate is 10 years before this year开发者_运维百科.

How do I do that?


You use the years= argument:

def someform(forms.Form):
    birthdate = forms.DateField(widget=SelectDateWidget(years=range(1990,2011))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜