If you want to check the request method, use if request.method == 'POST' .
request.POST is a post param dict, and you should not count on its existence or its absence when it comes to the request method. (for example, a send request without any parameters does not work in this test.)
Explicit is better than implicit. - PEP 20, Zen of Python
Yuval Adam
source share