On Dec 19, 8:28 pm, nbv4 <[email protected]> wrote:
> On Dec 19, 3:15 pm, DragonSlayre <[email protected]> wrote:
>
> > profile_form.user = user;
> > profile_form.save()
>
> The problem is that you can't assign fields in forms directly like
> this. The only way to input data into a form is when you initially
> create the form object ala:
>
> profile_form = ProfileForm(request.POST)
>
> If theres another way I'd love to know too, because I ran into this
> problem earlier and my only solution was to manually create an hidden
> textbox with the user_id.
<snip>

The easiest way is to do it like this:
new_profile = profile_form.save(commit=False)
new_profile.user = request.user
new_profile.save()
--
DR.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to