Django

Code

Ticket #2931 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: davidschein@alumni.tufts.edu Assigned to: jacob
Milestone: Component: Documentation
Version: Keywords:
Cc: gary.wilson@gmail.com Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Attachments

Change History

10/23/06 02:51:29 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

10/26/06 21:04:40 changed by Gary Wilson <gary.wilson@gmail.com>

  • status changed from closed to reopened.
  • resolution deleted.

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

10/26/06 21:08:28 changed by Gary Wilson <gary.wilson@gmail.com>

  • cc set to gary.wilson@gmail.com.

11/06/06 13:58:31 changed by Bastian Kleineidam <calvin@debian.org>

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

11/06/06 16:07:22 changed by SmileyChris

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

11/26/06 18:08:47 changed by adrian

  • status changed from reopened to closed.
  • resolution set to fixed.

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


Add/Change #2931 ("if request.POST" should read "if request.method == 'POST'")




Change Properties
Action