Exemplo n.º 1
0
def register_view(request):
    """ Rendering the registration form """
    if request.method == 'POST':
        form = RegistrationForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            email = form.clean_email()
            password = form.clean_password2()
            form.save()
            user = authenticate(request, email=email, password=password)
            if user is not None:
                login(request, user)
                messages.success(request,
                                 'Votre compte a été créé',
                                 extra_tags='toaster')
                return HttpResponseRedirect(reverse('home'))
    else:
        form = RegistrationForm()
    return render(request, 'users/signup.html', {'form': form})