user = request.user
initial = {}
if user.is_authenticated:
    initial.update({ 'name': user.name, 'email_address': user.email_address
})
form = MyContactForm(initial=initial)

On Wed, Jul 18, 2012 at 11:23 AM, Sithembewena Lloyd Dube <zebr...@gmail.com>
wrote:
> Hi everyone,
>
> I have a contact form in my app and would like to prepopulate it with user
> details where a user is logged in. Basically, I do the following:
>
> reg_user = get_registered_user(request)
> # get my form object
>
>
> I would like to do something like:
> if reg_user:
>     my_form.name = reg_user.name
>     my_form.email_address = reg_user.email_address
>     # and so on ...
>
> Any ideas? Thanks ...
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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