def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'register/signup.html', {'form': form})
def register(request): if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(request, username = username, password = password) login(request, user) return redirect('/home') else: form = SignUpForm() context = { "form": form } return render(request, 'register/signin.html', context)
def signup_view(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') messages.success(request, f'account created for {username}') user = authenticate(username=username, password=raw_password) login(request, user, backend='django.contrib.auth.backends.ModelBackend') return redirect('reg-profile') else: form = SignUpForm() context = {'form': form, 'title': 'Sign up', "terms": "terms"} return render(request, 'signup.html', context)
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string('account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})