Django - POST request

Should I use (and why?):

if request.POST 

or

 if request.method == 'POST' 

Are there any differences other than syntax?

+7
source share
1 answer

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

+9
source

All Articles