def Registration_View(request): form=SignUpForm() if request.method=='POST': form=SignUpForm(request.POST) user=form.save(commit=True) user.set_password(user.password) user.save() return HttpResponseRedirect('/accounts/login') return render(request, "MyApp/registration.html",{'form':form})
def create_new_user(request): if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): nowy_uzytkownik = form.save() Wspinacz.objects.create(opis_umiejetnosci="", user_id=nowy_uzytkownik.pk) return redirect('index') else: form = SignUpForm return render(request, 'registration/signup.html', {'form': form})
def test_rejestracja_email_powtorzony(self): data = { 'username': '******', 'first_name': 'adam', 'last_name': 'adamowski', 'email': '*****@*****.**', 'password1': 'verystrongpassword', 'password2': 'verystrongpassword' } User.objects.create(username='******', first_name='adam', last_name='adamski', email='*****@*****.**', password='******') form = SignUpForm(data=data) self.assertFalse(form.is_valid())
def Registration_View(request): form = SignUpForm() if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/accounts/login') return render(request, "MyApp/registration.html", {'form': form})