def post(self, request):
     form = CustomUserCreationForm(data=request.POST)
     if form.is_valid():
         form.save()
         return redirect('login')
     messages.error(request, form.error_messages)
     return redirect('login')
Exemple #2
0
 def post(self, request):
     user = CustomUserCreationForm(data=request.POST)
     if user.is_valid():
         user.save()
         return redirect('login')
     else:
         messages.error(request, user.error_messages)
         return redirect('register')
 def test_custom_user_creation_valid_form(self):
     form = CustomUserCreationForm(
         data={
             "username": "******",
             "password1": "FormsTests",
             "password2": "FormsTests"
         })
     self.assertTrue(form.is_valid())
 def test_custom_user_creation_no_data_form(self):
     form = CustomUserCreationForm(data={})
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 3)