Hi,

On 19.12.2008, at 21:15, DragonSlayre wrote:

>
> I've got a profile model which has a django.contrib.auth.models.User
> as a foreign key.
>
> I am trying to assign the User object to my profile model after I've
> checked that the user is valid and that the profile contents are also
> valid.
>
> Once I've saved my user object, I then call
>
> profile_form.user = user;
> profile_form.save()
>
I assume that you are using ModelForm to create your form.
If so, check the documentation [1] and you'll know that the save  
method returns the model instance.
So you should be able todo:

profile = profile_form.save()
profile.user = user
profile.save()

that'll cause 2 database hits, but should work fine.

adi

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