CSRF verification failed. Request aborted. on django

If you are using csrf_token template tag and the problem not solved, check CSRF_COOKIE_DOMAIN setting. You should set it to None on development environment.


You need to add the {% csrf_token %} template tag as a child of the form element in your Django template.

This way, the template will render a hidden element with the value set to the CSRF token. When the Django server receives the form request, Django will verify that the token matches the value that was rendered in the form. This is necessary to ensure that POST requests (i.e. data-altering requests) originate from an authentic client session.

For more info, check the Django documentation at: https://docs.djangoproject.com/en/dev/ref/csrf/

Here is an overview of the Cross-Site Request Forgery attack: https://www.owasp.org/index.php/CSRF


I had the same problem. I solved this problem when i added the {% csrf_token %}. Finally my code is this:

 <form id='formulario2' method='post' action='>
      <h3>Enter:</h3>
      {% csrf_token %}


     <input id="id_mesaje" name="mesaje" type="email" placeholder="E-mail"/>
    <input type='submit' name="boton2" value='Suscribete' style="display:inline-block;background-color: #80e174; "/>
 </form>