Your problem is not too clear.
You should post more information from you forms.py
and your views.py
. Are you using forms.Form
or forms.ModelForm
?
Either way I think your question is about using initial
data in your form.
Note that this field in particular accepts a python datetime
object (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:
f = ContactForm(initial={'my_date_field': datetime.datetime.now()})
If you are using ModelForm
is is like this:
f = ContactForm(instance=Contact.objects.get(pk=1))
This will initialise all the values from the models (and thus database).