Opened 10 years ago

Closed 10 years ago

#24145 closed Bug (fixed)

Extend POST redirect error to be raised on PUT and PATCH

Reported by: Samuel Colvin Owned by: Samuel Colvin
Component: Core (Other) Version: 1.7
Severity: Normal Keywords:
Cc: tom@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

As per https://github.com/tomchristie/django-rest-framework/issues/2405 discussion it would be extremely helpful if the exception raised when POST requests require a redirect

raise RuntimeError((""
"You called this URL via POST, but the URL doesn't end "
"in a slash and you have APPEND_SLASH set. Django can't "
"redirect to the slash URL while maintaining POST data. "
"Change your form to point to %s%s (note the trailing "
"slash), or set APPEND_SLASH=False in your Django "
"settings.") % (new_url[0], new_url[1]))

was extended to PUT and PATCH requests. PUT and PATCH requests have associated data which is generally lost with a redirect.

Code: https://github.com/django/django/blob/1.7.2/django/middleware/common.py#L75

Change History (10)

comment:1 by Tom Christie, 10 years ago

Cc: tom@… added
Component: contrib.redirectsCore (Other)
Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: New featureBug

comment:2 by Tom Christie, 10 years ago

I'm going to second this one. Our options are:

Of these, the first is the lesser change. It's unclear to me how widely supported 307/308 responses are supported by browsers and other clients.

comment:3 by Samuel Colvin, 10 years ago

Since it was easy I took the chance to try and get myself on the list of django contributors: https://github.com/django/django/pull/3908

comment:4 by Berker Peksag, 10 years ago

Has patch: set

comment:5 by arcturusannamalai, 10 years ago

@samuelcolvin please assign this geck to yourself. It is seems to have a solution you had developed, but looks as if it is not triaged.

comment:6 by Samuel Colvin, 10 years ago

Owner: changed from nobody to Samuel Colvin
Status: newassigned

comment:7 by Berker Peksag, 10 years ago

Triage Stage: AcceptedReady for checkin

PR #3908 LGTM.

comment:8 by Tim Graham, 10 years ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

I think some tests wouldn't hurt here (not sure if there's one for the existing behavior).

comment:9 by Tim Graham, 10 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 5b74134f27eabf92870e1c5e81f9e4999f113eab:

Fixed #24145 -- Added PUT & PATCH to CommonMiddleware APPEND_SLASH redirect error.

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