Django POST URL error Django POST URL error python python

Django POST URL error


First, make sure that you send the request to http://127.0.0.1/add/ not http://127.0.0.1/add.

Secondly, you may also want to exempt the view from csrf processing by adding the @csrf_exempt decorator - since you aren't sending the appropriate token from cURL.


For URL consistency, Django has a setting called APPEND_SLASH, that always appends a slash to the end of the URL if it wasn't sent that way to begin with. This ensures that /my/awesome/url/ is always served from that URL instead of both /my/awesome/url and /my/awesome/url/.

However, Django does this by automatically redirecting the version without the slash at the end to the one with the slash at the end. Redirects don't carry the state of the request with them, so when that happens your POST data is dropped.

All you need to do is ensure that when you send your POST, you send it to the version with the slash at the end.