def post(self, request): form = SignupForm(request.POST) if form.is_valid(): form.save() user = form.instance activate_url = self._get_activation_url(request, user) messages.success(request, SUCCESS_MESSAGES["account_created"]) send_email( "Activate your account on Paytime", SUCCESS_MESSAGES["kindly_verify"].format( user.get_full_name(), activate_url), "*****@*****.**", "*****@*****.**", ) return redirect("signup") return render(request, "authentication/signup.html", {"form": form})
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) mail_subject = 'Activate your blog account.' message = render_to_string( 'authentication/acc_active_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes( user.pk)).decode(), 'token': account_activation_token.make_token(user), }) to_email = form.cleaned_data.get('email') email = EmailMessage(mail_subject, message, to=[to_email]) email.send() return HttpResponse( 'Please confirm your email address to complete the registration' ) else: form = SignupForm() return render(request, 'authentication/signup.html', {'form': form})
def signup(request): signup_form = SignupForm(request.POST or None) user_profile_signup_form = UserProfileSignupForm(request.POST or None, request.FILES or None) if request.method == 'POST': if signup_form.is_valid() and user_profile_signup_form.is_valid(): with transaction.atomic(): user = signup_form.save(commit=False) user.username = user.email user.save() user_profile = user_profile_signup_form.save(commit=False) user_profile.user = user ui = UserInfo() ui.save() user_profile.info = ui user_profile.save() user = auth.authenticate(username=signup_form.cleaned_data['email'], password=signup_form.cleaned_data['password1']) auth.login(request, user) return HttpResponseRedirect('/') context = { 'signup_form': signup_form, 'user_profile_signup_form': user_profile_signup_form, 'title': 'Signup' } return render(request, 'signup.html', context)
def signup_view(request): if request.method == 'POST': form = SignupForm(request.POST) if form.is_valid(): logout(request) user = form.save() login(request, user) return HttpResponseRedirect(reverse('homepage')) form = SignupForm() return render(request, 'generic_form.html', {'form': form})
def signupView(request): if request.user.is_authenticated: return redirect('/') if request.method == 'POST': form = SignupForm(request.POST, request.FILES) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() verify_email(request, user) return HttpResponse( '<h1 align="center">Verify Your Email. Check Your Mailbox</h1>' ) else: form = SignupForm() context = {'form': form} return render(request, 'authentication/signup.html', context)
def signup(request): if request.method == 'POST': form = SignupForm(request.POST) if form.is_valid(): user = form.save(commit=False) username = form.cleaned_data['username'] password = form.cleaned_data['password1'] user.save() user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return redirect(reverse('auth:login')) else: return render(request, 'authentication/signup.html', {'form': form}) else: form = SignupForm() args = {'form': form} return render(request, 'authentication/signup.html', args)