> But if you use the user-profile approach, how do you create a single
> form for entering user data and profile data, and how do you process
> this form data in a view, including user creation, without handling
> each field separately, which is not in the Django (DRY) spirit?
You can display two forms, one for user data and one for profile data.
UserForm has a save method which creates and returns a new user.
ProfileForm has a save method which expects a user object.
def create_user(request):
if method=='POST':
user_form = UserForm(request.POST)
profile_form = ProfileForm(request.POST)
if user_form.is_valid() and profile_form.is_valid():
new_user = user_form.save()
profile_form.save(user=new_user)
return HttpResponseRedirect('/success/')
else:
user_form = UserForm()
profile_form = ProfileForm()
return
render_to_response('signup.html',{'user_form':user_form,'profile_form':profile_form})
Consider this pseudo code :)
HTH,
Daniel
> Rodney
>
> On Sep 16, 4:03 am, Erik Allik <[EMAIL PROTECTED]> wrote:
> > I guess if you subclassed the User model, you'd have to change all
> > places that use it to use YourUserModel instead, otherwise there's no
> > point (someone correct me if I'm wrong). So I'd stick with the user-
> > profile approach.
> >
> > Erik
> >
> > On 15.09.2008, at 17:33, Brot wrote:
> >
> >
> >
> > > Hello,
> >
> > > what is your preferred way for additional information for the user
> > > modell?
> > > Do you still use the User-Profile or do you subclass the auth.user
> > > model?
> > > What are the pros and cons?
> >
> > > ~Bernd
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---