I select date using DateField and insert date value using this.
form = DateField(widget=SelectDateWidget(years=BIRTH_YEAR_CHOICES))
and then, I want to show selected value using DateField(form) in HTML from database
(when create profileForm())
Birth: selectbox(------), selectbox(------), selectbox(------)
: solved
(if edit profile page using profileForm())
Birth: selectbox(1987) selectbox(10) selectbox(25)
-> I want it
How to insert value into DataField, and show selectDateWidget?
Your problem is not too clear.
You should post more information from you
forms.pyand yourviews.py. Are you usingforms.Formorforms.ModelForm?Either way I think your question is about using
initialdata in your form.Note that this field in particular accepts a python
datetimeobject (see: http://docs.python.org/2/library/datetime.html).https://docs.djangoproject.com/en/dev/ref/forms/api/#dynamic-initial-values
Use is like this:
If you are using
ModelFormis is like this:This will initialise all the values from the models (and thus database).