Opened 19 years ago
Closed 19 years ago
#888 closed defect (wontfix)
request.POST does not evaluate to True if there are no form variables
Reported by: | anonymous | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A common idiom encouraged by the docs is using if request.POST:
to see if a function was called using the POST method. But since request.POST is a dictionary-like thing, if the form that was POSTed contains no variables, request.POST evaluates to False. Since this idiom is much more common than the one testing for whether the form had contents, I suggest that request.POST should evaluate to True if the method is POST, regardless of whether there was form content.
Note:
See TracTickets
for help on using tickets.
if request.POST
is meant to be an idiom for checking whether any post data wasn't sent -- not whether the request method was POST.