When I add CSRF middleware django.middleware.csrf.CsrfViewMiddleware
to prevent xss csrf attack I am getting error response 403 csrf error.
- I referred to the official doc and old Stack Overflow answers but still I didn't get any idea why it causing error.
- I read from Django official doc if I added csrf middleware it will take care all csrf validation in every views by default.
- Along with this I have used some decorators too to ensure security like @login_required and @csrf_protect
- I have added
django.middleware.csrf.CsrfViewMiddleware
as a first entry before common middleware in Middleware class, is it because of that?