I implement {% csrf_token%} in my Django templates, but the token appears in the browser

38 Views Asked by At

enter image description herei am very new to django. i am trying to create a login form in django but when i write the csrf_token line after the tag it is showing in the browser view. everything is very confusing for me i don't know what to do. the tutorial that i watch on youtube only pass the csrf_token but don't say anything much.

{% csrf_token %} Email Password Sign In Change Password

this is a very simple form that i styled using tailwindcss and the csrf token is being shown. also my app has other errors. it does not run on the development server

1

There are 1 best solutions below

0
Amirhosseyn On

Did you edit your settings.py? Did you put {% csrf_token %} inside <form></form> ? 3 things comes to my mind is:

  1. check your settings.py for MIDDLEWARE and check if you have'django.middleware.csrf.CsrfViewMiddleware'.
  2. Check your template to see if you placed {% csrf_token %} inside your form.
  3. Check settings.py TEMPLATES section BACKEND if you have changed template engine. If you are using a custom template engine make sure it supports rendering this.