[Solved]-Django-rest-framework – POST Request returns "Method \"GET\" not allowed."


For anyone coming across this strange phenomenon of a POST request turning into a GET request mysteriously…

I’m using Django + DRF on Heroku. The problem was so simple it made me want to laugh and cry at the same time.

Heroku redirects requests to http://example.com to http://www.example.com, and this redirection involves a GET request. As a result, the POST request is received as a GET request without any of the headers or body that was initially present.

All of that work and frustration just for a missing ‘www’. Hope this helps somebody in the future!



You might also see this error if you don’t provide a trailing / on the end of your URL when building the request. For example, Django will give a 405 error for this request:

import requests

response = requests.post(
    headers={'Authorization': f'Token {authentication_token}'},


in my case, I ignore https:// prefix, so Nginx was redirecting backend.foo.com to https://backend.foo.com, and within this, method POST was changing to GET, so I just added https:// prefix and it worked

Leave a comment