Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SignupForm(authtoolsforms.UserCreationForm):
- def __init__(self, *args, **kwargs):
- super(SignupForm, self).__init__(*args, **kwargs)
- self.helper = FormHelper()
- self.fields["email"].widget.input_type = "email" # ugly hack
- company_name = forms.CharField()
- self.helper.layout = Layout(
- Field('email', placeholder="Enter Email", autofocus=""),
- Field('name', placeholder="Enter Full Name"),
- Field('company_name', placeholder="Company Name"),
- Field('password1', placeholder="Enter Password"),
- Field('password2', placeholder="Re-enter Password"),
- Submit('sign_up', 'Sign up', css_class="btn-warning"),
- )
- class SignUpView(bracesviews.AnonymousRequiredMixin,
- bracesviews.FormValidMessageMixin,
- generic.CreateView):
- form_class = forms.SignupForm
- model = User
- template_name = 'accounts/signup.html'
- success_url = reverse_lazy('home')
- form_valid_message = "You're signed up!"
- def form_valid(self, form):
- r = super(SignUpView, self).form_valid(form)
- username = form.cleaned_data["email"]
- password = form.cleaned_data["password1"]
- user = auth.authenticate(email=username, password=password)
- auth.login(self.request, user)
- return r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement