Opened 17 years ago

Closed 17 years ago

#2931 closed defect (fixed)

"if request.POST" should read "if request.method == 'POST'"

Reported by: davidschein@… Owned by: Jacob
Component: Documentation Version:
Severity: minor Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

From http://www.djangoproject.com/documentation/request_response/#httprequest-objects
we have:

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).

Then in http://www.djangoproject.com/documentation/forms/
we violate that advice with:

def create_place(request):
    manipulator = Place.AddManipulator()

    if request.POST:
    ...

Change History (6)

comment:1 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [3914]) Fixed #2931 -- Use request.method == 'POST' where appropriate in the examples.
Thanks, David Schein.

comment:2 by Gary Wilson <gary.wilson@…>, 17 years ago

Resolution: fixed
Status: closedreopened

request.POST is used once elsewhere in the docs and several places in trunk too that maybe should be changed.

comment:3 by Gary Wilson <gary.wilson@…>, 17 years ago

Cc: gary.wilson@… added

comment:4 by Bastian Kleineidam <calvin@…>, 17 years ago

Hmm, should that be request.method.lower() == 'post' to be really sure? Just nitpicking, though.

comment:5 by Chris Beaven, 17 years ago

.lower() shouldn't be necessary: according to documentation, request.method will always return an uppercase value.

comment:6 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: reopenedclosed

(In [4110]) Fixed #2931 -- Changed 'if request.POST' to 'if request.method == POST' in docs/sessions.txt

Note: See TracTickets for help on using tickets.
Back to Top