On Jan 20, 12:56 pm, "shogunm...@googlemail.com"
<shogunm...@googlemail.com> wrote:
> Hi Thomas,
>
> Thanks for your quick reply!
>
> I had a look at the docs, but it seems I have to enter the initial
> values at the Form definition level. However, I am interested in
> entering dynamic data depending on who is viewing the form. For
> instance, in my case I want the user's email address to be displayed
> in the form when they view the page. Since the form definition doesn't
> have access to the request object, I presume this is not possible.
>
> Is there any other way to do this?
>
> Thanks,
>
> Mike.

No, you can pass initial data when you instantiate the form in your
view.

f = MyFormClass(initial=initial_data)

See here: 
http://docs.djangoproject.com/en/dev/ref/forms/fields/#dynamic-initial-values
I have to admit it took some searching before I could find this link,
even though I knew it was there; the 'fields' page doesn't seem like a
very obvious place for it.

--
DR.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to