def signup_view(request): if request.method == 'GET': from home.forms import RegistrationForm form = RegistrationForm args = {'form': form} return render(request, 'home/signup.html', args) else: from home.forms import RegistrationForm form = RegistrationForm(request.POST) if form.is_valid(): email = form.cleaned_data['email'] user = User.objects.filter(email=email) if user.count() == 0: saved = form.save(commit=False) username = form.cleaned_data['username'] password = form.cleaned_data['password1'] saved.email = form.cleaned_data['email'].lower() saved.save() user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return redirect('home:home') else: messages.add_message(request, messages.ERROR, 'email has already been used') return render(request, 'home/signup.html', {'form': form}) else: return render(request, 'home/signup.html', {'form': form})
def register(request): # 20210325 if request.method == 'POST': form = RegistrationForm(request.POST) print("Errors", form.errors) 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') email = form.cleaned_data.get('email') user = authenticate(username=username, password=raw_password, first_name=first_name, last_name=last_name, email=email) login(request, user) # print('user created!!!') messages.success(request, 'Account created successfully') return render(request, 'index.html') else: messages.success(request, 'Account created " NOT " successfully') context = {'form': form} return render(request, 'registration/signup.html', context) else: form = RegistrationForm() context = {'form': form} return render(request, 'registration/signup.html', context)
def register(request): if request.method == "POST": form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('/home') else: form = RegistrationForm() args = {'form': form} return render(request, 'home/regis.html', args)
def registration(request): form = RegistrationForm() if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() #messages.success(request, "Registration successfully completed") return redirect('/') return render(request, 'home/register.html', {"form": form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() update_session_auth_hash(request, form.user) return redirect('/home') form = RegistrationForm() args = {'form': form} return render(request, 'home/reg_form.html', args)
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect(reverse('home:home')) else: form = RegistrationForm() args = {'form': form} return render(request, 'home/reg_form.html', args)
def register_page(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user( username=form.cleaned_data['username'], password=form.cleaned_data['password1'], email=form.cleaned_data['email'], ) return HttpResponseRedirect('/accounts/register/success/') else: form = RegistrationForm() return render_to_response('registration/register.html',{'form':form}, context_instance=RequestContext(request))
def register(request): form = RegistrationForm() if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() new_user = authenticate( username=form.cleaned_data['username'], password=form.cleaned_data['password1'], ) login(request, new_user) return render(request, 'home/register-success.html') return render(request, 'home/register.html', {'form': form})
def SignUpController(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() emailadd = form.cleaned_data.get('email') raw_password = form.cleaned_data.get('password1') user = authenticate(email = emailadd, password=raw_password) login(request, user) return redirect('/') else: form = RegistrationForm() return render(request, 'signup/SignUpUI.html', {'form': form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('photo') else: return HttpResponse(u'Форма не валідна') else: form = RegistrationForm() args = {'form': form} return render(request, 'accounts/reg_form.html', args)
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/accounts/register/complete') else: form = RegistrationForm() token = {} token.update(csrf(request)) token['form'] = form return render_to_response('registration/registration_form.html', token)
def register(request): if request.method =='POST': form = RegistrationForm(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) return redirect(reverse('home:view_profile')) else: form = RegistrationForm() args = {'form': form} return render(request, 'home/register.html', args)
def register(request): #if data is posted (from user submission) perform this if request.method == 'POST': #form reads user input form = RegistrationForm(request.POST) #if the form contains valid data perform this if form.is_valid(): #save information and redirect to specified location form.save() return redirect('/home') #if request method is 'get' generate empty form else: form = RegistrationForm() args = {'form': form} return render(request, 'personal/register.html', args)
def post(self, request): form = RegistrationForm(request.POST) if form.is_valid(): result = self.validateRecaptcha( request.POST.get('g-recaptcha-response')) if result['success']: participant = form.save(request) return HttpResponseRedirect('/thank-you') else: messages.error(request, 'Invalid reCAPTCHA. Please try again.') return TemplateResponse(request, 'home/index.html', { 'registration_form': form, 'invalid': True }) else: return TemplateResponse(request, 'home/index.html', { 'registration_form': form, 'invalid': True })
def register(request, template='home/register.html'): if request.LANGUAGE_CODE == 'en': translation = English_Dict else: translation = Chinese_Dict if request.method == 'POST': form = RegistrationForm(data=request.POST) if form.is_valid(): username = form.cleaned_data['username'] email = form.cleaned_data['email'] password = form.cleaned_data['password1'] user = User.objects.create_user(username, email, password) user.is_active = False user.save() #send a confirmation message messages.success(request, "Account Created!") return HttpResponseRedirect(reverse("home")) else: form = RegistrationFormUniqueEmail() vals = dict(form=form, register=True, layout='horizontal', translation=translation) return render_to_response(template, RequestContext(request, vals))
def signup_view(request): if request.method == 'POST': form = RegistrationForm(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 Event Manager account.' message = render_to_string( 'home/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 render(request, 'home/email_confirm.html') else: form = RegistrationForm() return render(request, 'home/signup.html', {'form': form})