def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('/myapp') else: form = RegistrationForm() return render(request, 'myapp/register.html', {'form': form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('myapp:login')) else: form = RegistrationForm() return render(request, 'myapp/register.html', {'form': form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect(reverse('myapp:home')) else: form = RegistrationForm() args = {'form': form} return render(request, 'reg_form.html',args)
def register(request): """Registartion page""" if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('login') else: form = RegistrationForm() context = {'form': form} return render(request, 'registration/register.html', context)
def register(request): if request.method == 'POST': form = RegistrationForm(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(reverse('myapp:index')) else: form = RegistrationForm() return render(request, 'myapp/register.html', {'form': form})
def registration_view(request): try: cart_id = request.session['cart_id'] cart = Cart.objects.get(id=cart_id) request.session['total'] = cart.items.count() except: cart = Cart() cart.save() cart_id = cart.id request.session['cart_id'] = cart_id cart = Cart.objects.get(id=cart_id) form = RegistrationForm(request.POST or None) categories = Category.objects.all() if form.is_valid(): new_user = form.save(commit=False) first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['password'] email = form.cleaned_data['email'] username = form.cleaned_data['username'] password = form.cleaned_data['password'] new_user.first_name = first_name new_user.last_name = last_name new_user.email = email new_user.username = username new_user.set_password(password) new_user.save() aunth_user = authenticate(username=username, password=password) if aunth_user: login(request, aunth_user) return HttpResponseRedirect(reverse('main_page')) context = {'form': form, 'categories': categories} return render(request, 'registration.html', context)
def register(request): if request.method=='POST': form=RegistrationForm(request.POST) if form.is_valid(): user=form.save(commit=False) user.set_password(form.cleaned_data['password']) user.save() else: return render(request,"myapp/register.html",{'form':form}) form=RegistrationForm() return render(request,"myapp/register.html",{'form':form})
def post(self, request, *args, **kwargs): form = RegistrationForm(request.POST) if form.is_valid(): new_user = form.save(commit=False) new_user.username = form.cleaned_data['username'] new_user.email = form.cleaned_data['email'] new_user.name = form.cleaned_data['name'] new_user.save() new_user.set_password(form.cleaned_data['password']) new_user.save() user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password']) login(request, user) messages.success(request, 'Welcomm in our club') return HttpResponseRedirect('/') context = {'form': form} return render(request, 'registration.html', context)
def register(request): args = {} args.update(csrf(request)) if request.method == 'POST': form = RegistrationForm(request.POST) args['form'] = form if form.is_valid(): form.save() # save user to database if form is valid # Email Verification Starts Here username = form.cleaned_data['username'] email = form.cleaned_data['email'] salt = hashlib.sha1(str(random.random())).hexdigest()[:5] activation_key = hashlib.sha1(salt+email).hexdigest() key_expires = datetime.today() + timedelta(2) print key_expires #Get user by username user=User.objects.get(username=username) user.is_active = True user.save() # Create and save user profile new_profile = UserProfile(user=user, activation_key=activation_key, key_expires=key_expires) new_profile.save() # Send email with activation key #send_mial(subject,message,from_email,to_list,fail_silently=True) email_subject = 'Company Name - Account confirmation' email_body = "Hey %s, thanks for signing up. To activate your account, click this link within \ 48hours http://127.0.0.1:8000/user_confirm/%s" % (username, activation_key) from_email = settings.EMAIL_HOST_USER # template = get_template('verification_email.html') # context = Context({'username': username, 'activation_key': activation_key}) html_message = ''' <div style="border:1px solid black; margin:5px"> <strong>Dear %s,</strong></br>activation_key <p> Greetings from Company Name. Thank you for registering with us<p> <p> Please click on below button to complete registration</p> <div style="text-align:center"> <input type="button" href="http://127.0.0.1:8000/user_confirm/%s" value="Click here to complete registration"> </div> <p> If the button is not visible, please click on below link or copy-paste the url in browser:</p> http://127.0.0.1:8000/user_confirm/%s <p> If you face any difficulties, write to us at <a style="color:blue; font-weight:bold">[email protected]</a > or call us on <a style="color:blue; font-weight:bold">(+91) 8179608300</a></p></br> <strong>Have a great day!!!</strong> </br> </br> <p>Regards,</p> <p>SuportTeam, NearByMedics</p> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> ''' % (username, activation_key, activation_key) # html_message = template.render(context) # send_mail(email_subject, email_body, settings.EMAIL_HOST_USER, [user.email], fail_silently=True, html_message = html_message) args['form'] = RegistrationForm() args['register_success'] = True return render(request,'register.html', args ) else: form = RegistrationForm() args['form'] = form args['register_success'] = False return render(request,'register.html', args)