Userena group based categorization on signup/registration

36 views Asked by At

I would like to separate users into two different groups, sellers or buyers, at signup. I'm using django-userena and for the authentication and registration of users. I'm thinking of using a clone of the same signup view except with a different url tied to it.

So whoever signs up at url(r'^account/signup/seller/$) linked to a seller signup button will be added to the seller group and whoever signs up at url(r'^account/signup/$) linked to a buyer signup button will be added to the buyer group.

Note: I will be using this grouping to grant access to view functions in another django app in my project via signals/decorators.

in my accounts/form.py file, I have:

class SellerSignupFormExtra(SignupForm): 
    def save(self): 
    new_user = super(SignupFormExtra, self).save()
    new_user.groups.add(Group.objects.get(name=‌​'seller')) 
    return new_user

and I added this to accounts/urls.py file

url(r'^accounts/signup/seller$', 'userena_views.signup', {'signup_form': SellerSignupFormExtra}),

So my question is that can I add the other users that click the buyer signup button by doing the same thing I did for sellers above or is their a better way to achieve this so that I remain DRY.

0

There are 0 answers