The application I'm working on requires a separate login for two different types of users. We need the owners of "customers" and "business" in order to be able to register.
For the owner of "business", all I have to do is set boolean user.is_businesstoTrue
I used ACCOUNT_SIGNUP_FORM_CLASSwith a separate class that sets the boolean to true and works like a charm. But then the client login no longer works.
Is there a way to create a separate registration type for another user?
I tried the following
class BusinessUserRegistrationView(FormView):
form_class = BusinessSignupForm
template_name = 'allauth/account/signup.html'
view_name = 'organisersignup'
success_url = reverse_lazy(view_name)
organisersignup = BusinessUserRegistrationView.as_view()
And form
class BusinessSignupForm(BaseSignupForm):
password1 = SetPasswordField(label=_("Password"))
password2 = PasswordField(label=_("Password (again)"))
confirmation_key = forms.CharField(max_length=40,
required=False,
widget=forms.HiddenInput())
def __init__(self, *args, **kwargs):
super(BusinessSignupForm, self).__init__(*args, **kwargs)
if not app_settings.SIGNUP_PASSWORD_VERIFICATION:
del self.fields["password2"]
def clean(self):
super(BusinessSignupForm, self).clean()
if app_settings.SIGNUP_PASSWORD_VERIFICATION \
and "password1" in self.cleaned_data \
and "password2" in self.cleaned_data:
if self.cleaned_data["password1"] \
!= self.cleaned_data["password2"]:
raise forms.ValidationError(_("You must type the same password"
" each time."))
return self.cleaned_data
def save(self, request):
adapter = get_adapter()
user = adapter.new_user(request)
user.is_business = True
adapter.save_user(request, user, self)
self.custom_signup(request, user)
setup_user_email(request, user, [])
return user
And in urls.py
url(r'^organiser/$', 'authentication.views.organisersignup', name='organisersignup'),
, , is_business True.
, , , , . BusinessSignupForm - SignUpForm, allauth.
?