title: Writing Django signup form tests for checking new user creation
body: <p>Implemented a custom user model in Django and allows user to signup using the url <a href="http://127.0.0.1:8000/users/signup/" rel="noreferrer">http://127.0.0.1:8000/users/signup/</a>. A GET request on this url is displayed like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Wabka.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wabka.png" alt="enter image description here"></a></p>
  
  <p>I have written tests for this page. Tests for <code>get</code> is working as expected.</p>
  
  <p>I wrote test for <code>post</code> with the intention that the post would create a user in the test database. After which I could write tests to confirm if an user is created and whether the username matches and so on. But it seems the user is not getting created. Below are my tests</p>
  
  <pre class="lang-py prettyprint-override"><code>class SignUpPageTests(TestCase):
      def setUp(self) -&gt; None:
          self.username = 'testuser'
          self.email = 'testuser@email.com'
          self.age = 20
          self.password = 'password'
  
      def test_signup_page_url(self):
          response = self.client.get("/users/signup/")
          self.assertEqual(response.status_code, 200)
          self.assertTemplateUsed(response, template_name='signup.html')
  
      def test_signup_page_view_name(self):
          response = self.client.get(reverse('signup'))
          self.assertEqual(response.status_code, 200)
          self.assertTemplateUsed(response, template_name='signup.html')
  
      def test_signup_form(self):
          response = self.client.post(reverse('signup'), data={
              'username': self.username,
              'email': self.email,
              'age': self.age,
              'password1': self.password,
              'password2': self.password
          })
          self.assertEqual(response.status_code, 200)
  
          users = get_user_model().objects.all()
          self.assertEqual(users.count(), 1)
  </code></pre>
  
  <p>The users.count() turns out to be 0 and my test is failing. Where am I going wrong?</p>