I am trying to make a sign up form and there I want to get the users birth date. I want to use the select date widget. in my models.py I have set a model field:

birth_date = models.DateField(verbose_name='Birth Date')

and my forms.py looks like this:

from django import forms
from django.forms.extras import SelectDateWidget
from models import UserProfile
import datetime

yearNow = datetime.date.today().year


class UserProfileForm(forms.ModelForm):
    class Meta:
        model = UserProfile

localized_fields = ('gender', 'birth_date', 'has_accepted_tos', 'is_18_or_older')
        widgets = {
'birth_date': SelectDateWidget(years=reversed(range(yearNow - 100, yearNow - 18)))
        }

The problem is that I don't always get a list of years. The first time I access the form it works fine. If I reload the form I get a list for the months, for the days but the list of the years just shows a '---'.

How can I fix this?

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52ADC123.8000904%40yahoo.gr.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to