I use two registration forms one for clients one for vendors.
Depending on form used I would like to assign the user to a group.
How do I use new_user.groups.add('Client')
Below is my code that does not raise any errors but also does not add
the user to the group.
===== CODE =====
def register(request, success_url='/accounts/register/complete/'):
Context::
form
The registration form
Template::
registration/registration_form.html
"""
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
new_user =
RegistrationProfile.objects.create_inactive_user(username=form.clean_data['username'],
password=form.clean_data['password1'],
email=form.clean_data['email'])
new_user.groups.add('Client')
return HttpResponseRedirect(success_url)
else:
form = RegistrationForm()
return render_to_response('registration/registration_form.html',
{ 'form': form },
context_instance=RequestContext(request)
)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---