def index(request): if request.method == 'POST': registration = SignUpForm(request.POST) if registration.is_valid(): registration.save() username = registration.cleaned_data.get('username') raw_password = registration.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('mainpage') else: registration = SignUpForm() if request.method == 'POST': login_form = LogInForm(request.POST) if login_form.is_valid(): login_form.save() username = login_form.cleaned_data.get('username') password = login_form.cleaned_data.get('password') user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return redirect('mainpage') else: return redirect('http://facebook.com') else: login_form = LogInForm() return render(request, 'homepage.html', { 'registration': registration, 'login': login_form })
def signup(request): if request.user.is_authenticated: return HttpResponseRedirect(reverse('index')) if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() user.profile.pen_name, user.profile.bio = form.cleaned_data.get('pen_name'), form.cleaned_data.get('bio') if form.cleaned_data['photo']: user.profile.photo = form.cleaned_data['photo'] user.profile.save() user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return HttpResponseRedirect(reverse('index')) else: form = SignUpForm() context = { 'form': form } return render(request, 'signup.html', context=context)
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() return redirect('list') else: form = SignUpForm() return TemplateResponse(request, 'blog/signup.html', {'form': form})
def sign_up_view(request): form = SignUpForm() if request.method == 'POST': form = SignUpForm(request.POST) user = form.save() user.set_password(user.password) user.save() return redirect('index') return render(request, 'blog/signup.html', locals())
def signup_view(request): form = SignUpForm() if request.method == 'POST': form = SignUpForm(request.POST) user = form.save() user.set_password(user.password) user.save() return HttpResponseRedirect('/accounts/login') return render(request, 'blog/signup.html', {'form': form})
def createUser(request): # template_name='blog/signup.html' if request.method == 'POST': userform = SignUpForm(request) userform = SignUpForm() userformPart = SignUpFormPart() return render(request, 'blog/signup.html', { 'userform': userform, 'userformPart': userformPart })
def signup_view(request): form=SignUpForm() if request.method=='POST': form=SignUpForm(request.POST) if form.is_valid(): username=form.cleaned_data.get('username') user=form.save() user.set_password(user.password) user.save() messages.success(request,f' Account Created Successfully for {username} ! Now you can Login') return HttpResponseRedirect('/accounts/login') return render(request,'blog/signup.html',{'form':form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password') login(request, user) return redirect('post_list') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
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, 'signup.html', {'form': form})
def signup(request): pos = User.objects.all() 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) return redirect('login') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def createaccount(request): form = SignUpForm() if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): myuser = form.save() author_group = Group.objects.get(name='author') myuser.groups.add(author_group) messages.success( request, 'your account created. now you can login into your account') return HttpResponseRedirect('/login') context = {} context['form'] = form return render(request, 'blog/signup.html', context)
def register_user(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data['username'] password = form.cleaned_data['password1'] user = authenticate(username=username, password=password) login(request, user) messages.success(request, ('Youre now registered')) return redirect('/home') else: form = SignUpForm() context = {'form': form} return render(request, 'register.html', context)
def sign_up(): """SIGN-UP page which allows users to register.""" if current_user.is_authenticated: flash("You have alredy logged in.") return redirect(url_for("app.home")) else: form = SignUpForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None: user = User(username=form.username.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() login_user(user) flash("Sucessfully registered.") flash("Sucessfully logged in.") return redirect(url_for("app.home")) flash("A user already exists with that email address.") return render_template( "sign-up.html", form=form, page_title="SIGN-UP", page_color="black", )
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) redirect_to = (request.POST.get("next", "").replace( "/accounts/signin/?next=", "").replace("/en", "")) if "accounts/" in redirect_to or redirect_to == "": return redirect("home") return HttpResponseRedirect(redirect_to) else: form = SignUpForm() return render(request, "signup.html", {"form": form})
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') first_name = form.cleaned_data.get('first_name') last_name = form.cleaned_data.get('last_name') biography = form.cleaned_data.get('biography') user = authenticate(username=username, password=raw_password) login(request, user) new_author = Author.objects.create(user=request.user.id, first_name=first_name, last_name=last_name, biography=biography) return redirect('/') else: form = SignUpForm() return render(request, 'sign_up.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) 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})
def signup(request): if request.user.is_authenticated(): return HttpResponseRedirect('/') if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') email = form.cleaned_data.get('email') password = form.cleaned_data.get('password') User.objects.create_user(username=username, email=email, password=password) user = authenticate(username=username, password=password) if user is not None: auth_login(request, user) return HttpResponseRedirect('/') else: return HttpResponseRedirect('/login') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})