24đź‘Ť
âś…
The documentation is clear about this:
It’s possible that a request can come in via POST with an empty POST dictionary — if, say, a form is requested via the POST HTTP method but does not include form data. Therefore, you shouldn’t use if request.POST to check for use of the POST method; instead, use if request.method == “POST” (see above).
>>> # assume an empty POST request would be treated as a dict
>>> bool({})
False
>>> # it would be a POST request, but request.POST would evaluate to False
👤miku
Source:stackexchange.com