Skip to content
Advertisement

How to stop Getting 405 error Method not allowed?

I am trying to make my django project to work but somehow I always come to get this error

Method Not Allowed (POST): /

I have tried using decorators like @csrf_exempt like in the django documentation as to not encounter csrf errors and yet I came to this error.Please tell me what’s the problem with my code…

urls.py

JavaScript

views.py

JavaScript

app.js

JavaScript

homepage.html

JavaScript

Advertisement

Answer

Method Not Allowed (POST): / – means your function is not accepting post methos it accpets only get or other safe methods.
you’re not changing any state of your database so you don’t have to use post request you can use get intead of post

JavaScript

and change your urls like this

JavaScript

and in your javascript change method post to get

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement