def test_password_confirmation_is_valid(self): data = { 'email': '*****@*****.**', 'password': '******', 'same_password_again': 'abc123' } form = forms.SignupForm(data) self.assertTrue(form.is_valid())
def post(self, request): form = forms.SignupForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect('/') context = {"forms": form} return render(request, 'auth/signup.html', context)
def test_password_confirmation_is_invalid(self): data = { 'email': '*****@*****.**', 'password': '******', 'same_password_again': 'not the same' } form = forms.SignupForm(data) self.assertFalse(form.is_valid()) self.assertIn(u'You must type the same password twice!', form.errors['same_password_again'])
def get(self, request): context = {"form": forms.SignupForm()} return render(request, 'auth/signup.html', context)