D4NieLDev
D4NieLDev

Reputation: 300

How to tell browser that the form was wrong and do not save password

I have a website with a login form. My problem is that every time this form is submitted, chrome suggests to save the password, even if it's incorrect

The form:

<form method="POST" action="" id='sign-in'>
  {% csrf_token %}
        
  <div class="form-group inner-addon">
    <input name="txt_login_username" type="text" class="form-control" placeholder="Username">
    <i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
  </div>

  <div class="form-group inner-addon">
    <input name="txt_login_pass" type="password" class="form-control" placeholder="Password">
    <i class="fa fa-key fa-lg fa-fw" aria-hidden="true"></i>
  </div>

  {% for message in messages %}
  <p class='alert alert-danger'>{{ message }}</p>
  {% endfor %}

  <button type="submit" class="btn btn-primary" name="btn_login">Log In</button>
</form>

Upvotes: 0

Views: 41

Answers (1)

D4NieLDev
D4NieLDev

Reputation: 300

I figured it out with the help of @deceze. just need to add state=400 to the render method:

render(request, 'index.html', context, status=400)

Upvotes: 1

Related Questions