def post(self, request): form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') ## if form is valid then create a new user self.add_new_user(form) ## USer Authentication Part user = authenticate(username=username, password=password) login(request, user) return redirect('index') return render(request, 'landing_page.html', {'form': form})
def signup(request): """View function for user signup in the sign-up form.""" # If this is a POST request then process the Form data if request.method == 'POST': # Create a form instance and populate it with data from the request (binding): form = SignUpForm(request.POST) # Check if the form is valid: if form.is_valid(): # process the data in form.cleaned_data as required # bst = NameAgeBst(name=form.cleaned_data['name'], # age=form.cleaned_data['age'], # key="name") # bst.save() # bst = NameDateBst(name=form.cleaned_data['name'], # date=form.cleaned_data['date'], # key="name") # bst.save() # sl = NameSortedList(name=form.cleaned_data['name']) # sl.save() # mh = AgeMinHeap(age=form.cleaned_data['age']) # mh.save() # ht = NameGPAHashTable(name=form.cleaned_data['name'], # gpa=form.cleaned_data['gpa'], # key="name") # ht.save() sign_up_model = SignUp(name=SpliceStr(form.cleaned_data['name']), age=SpliceInt(form.cleaned_data['age'])) sign_up_model.save() # redirect to a new URL: return HttpResponseRedirect(reverse('signup')) # If this is a GET (or any other method) create the default form else: form = SignUpForm() context = { 'form': form, } return render(request, 'catalog/signup.html', context)
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('login') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): # POST in HTTP basically means that the user is sending data as opposed to receiving it if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: form = SignUpForm() args = {'form': form} return render(request, 'users/signup.html', args)
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') university = form.cleaned_data.get('university') user = form.save() login(request, user) return redirect('catalog:index') else: form = SignUpForm() return render(request, 'catalog/signup.html', {'form': form})
def signup_view(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): # form.clean_password2() user = form.save(commit=False) # email = form.cleaned_data.get('email') password = form.clean_password2() user.set_password(password) user.save() new_user = authenticate(email=user.email, password=password) login(request, new_user) return redirect('locallibrary') else: form = SignUpForm() context = { 'form': form, } return render(request, 'signup.html', context=context)
def signup_view(request): form = SignUpForm(request.POST) print("post request") if form.is_valid(): print("valid form") user = form.save() user.refresh_from_db() user.profile.first_name = form.cleaned_data.get('first_name') user.profile.last_name = form.cleaned_data.get('last_name') user.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(username=username, password=password) login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) pform = ProfileForm(request.POST) if form.is_valid() and pform.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal user.profile.contact = pform.cleaned_data.get('contact') user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('houses') else: form = SignUpForm() pform = ProfileForm() return render(request, 'signup.html', {'form': form, 'pform': pform})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal user.profile.bio = form.cleaned_data.get('bio') user.profile.gender = form.cleaned_data.get('gender') user.profile.picture_url = form.cleaned_data.get('picture_url') user.profile.profileUsername = user.username user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) django_login(request, user) return redirect('index') 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(): user = form.save() user.refresh_from_db() print(user) number_of_rooms = form.cleaned_data.get('number_of_rooms') user.save() current_user=User.objects.get(username=user) current_user_id=current_user.id profile = Profile.objects.create(user_id=current_user_id, number_of_rooms=number_of_rooms) profile.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('login') 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(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) email_subject = 'Activate Your Account' message = render_to_string( 'registration/account_activation_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(email_subject, message, to=[to_email]) email.send() return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def get(self, request): if request.user.is_authenticated: return HttpResponseRedirect(reverse('index')) else: form = SignUpForm(initial={}) return render(request, 'landing_page.html', {'form': form})