Sorry for late response. Thanks kenneth and oscar, it really helps! On Tue, Jun 5, 2012 at 1:05 PM, Oscar Mederos <omede...@gmail.com> wrote:
> On Monday, June 4, 2012, 11:04:58 PM, you wrote: > > > Hi All, > > I want to create list of year select form. > > I know that i can generate the value using html. > > Is there a way to generate the value using forms API. > > > For example, i want to generate select field that display year from > 1970-2011. > > > Thanks > > What about using the 'SelectDateWidget' widget from > 'django.forms.extras.widgets'? You could so something like: > > You can pass a list of years to the constructor. Something like: > > from django.forms.extras.widgets import SelectDateWidget > class MyForm(forms.Form): > ... > date = forms.DateField(widget=SelectDateWidget(years=range(1970, > datetime.today().year))) > ... > > > Take a look at the source code of the widget. For example, some time > ago I created my own SelectDateWidget to override the 'none_value' it > places by default (---). > > -- > Oscar Mederos > omede...@gmail.com > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.