On Sat, Jun 25, 2011 at 1:00 PM, CareerDhaba tech <t...@careerdhaba.com>wrote:

> The user model is getting saved with username and password but the
> userprofile isn;t :(


That is a somewhat misleading description of the problem since the code as
you have posted it would not just fail to save the userprofile it would
raise an exception on the attempt to pass user to RegForm, since RegForm as
you have shown it is not expecting user as a keyword argument.

The right way to handle saving model forms which have explicitly excluded
necessary data is described here:
https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

In this case you would want to save the originally-created RegForm instance
uprofile with comit=False, then set the user attribute to the user returned
by the other form save, then save the user profile instance:

up = uprofile.save(commit=False)
up.user = userid
up.save()

Karen
-- 
http://tracey.org/kmt/

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