Opened 9 years ago

Closed 9 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: UI/UX:

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 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

comment:3 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Cc gary.wilson@… added

comment:4 Changed 9 years ago by Bastian Kleineidam <calvin@…>

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

comment:5 Changed 9 years ago by SmileyChris

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

comment:6 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from reopened to closed

(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