Answers for "django registration form"

0

signup view

from django.contrib.auth import authenticate

class SignUpView(CreateView):
    form_class 		= UserRegistrationForm
    success_url 	= reverse_lazy('home')
    template_name	= 'registration/signup.html'
    
    def form_valid(self, form):
        view        = super(SignUpView, self).form_valid(form)
        username    = form.cleaned_data.get('username')
        password    = form.cleaned_data.get('password1')
        user        = authenticate(username=username, password=password)       
        login(self.request, user)
        return view
Posted by: Guest on September-16-2020
0

django registration form

from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


# Create your forms here.

class NewUserForm(UserCreationForm):
	email = forms.EmailField(required=True)

	class Meta:
		model = User
		fields = ("username", "email", "password1", "password2")

	def save(self, commit=True):
		user = super(NewUserForm, self).save(commit=False)
		user.email = self.cleaned_data['email']
		if commit:
			user.save()
		return user
Posted by: Guest on October-16-2021

Code answers related to "django registration form"

Python Answers by Framework

Browse Popular Code Answers by Language