title: Django how to count failed login attempt for prevent brute force attack?
body: <p>I know there have few package available like <a href="https://pypi.org/project/django-defender/" rel="nofollow noreferrer">django-defender</a>, <a href="https://pypi.org/project/django-axes/" rel="nofollow noreferrer">django-axes</a> etc for prevent brute force attack. I am thinking to prevent brute force attack <strong>by showing captcha</strong> using <strong>Django session</strong>( I want to use session for count failed login attempts) or somethings like this <strong>without help of any package</strong>. I want to count failed login attempt in my views then it will show the captcha after number of failed login attempts. So it will be simple two step:</p>
  <p><strong>step1)</strong> it will count the failed login attempts.</p>
  <p><strong>step2)</strong> It will show the captcha after number of failed login attempts</p>
  <p>here is my
  <strong>views.py</strong> :</p>
  <pre><code>def login_view(request):
       if request.method == 'POST':
              username = request.POST.get('username')
              password =request.POST.get('password')
              user = authenticate(request, username=username, password=password)
              
              if user is not None:
                    login(request, user)
                    messages.add_message(request, messages.INFO,'Login Sucessfull')  
              else:
                    messages.info(request, &quot;wrong username or password&quot;)
  </code></pre>