Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#19321 closed New feature (fixed)

Add django.contrib.redirects setting for redirect status.

Reported by: Lebedev Ilya Owned by: Lebedev Ilya
Component: contrib.redirects Version: dev
Severity: Normal Keywords: redirects, status_code
Cc: Lebedev Ilya, unai@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

At the moment django.contrib.redirects redirects only with status 301(Moved Permanently).
It doesn't allow to use django.contrib.redirects if user needs temporary redirect (one of 302/303/307).
This can be solved easily with with adding optional parameter REDIRECT_STATUS_CODE=301/302/303/307.
It will make redirects middleware more flexible and convenient.

Attachments (1)

19321.patch (1.5 KB ) - added by Aymeric Augustin 12 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 1.4master

The trend is more to add a redirect_class (HttpResponseRedirectBase subclass) attribute instead of setting the status code directly (see #19277). But yes, this seems to be a reasonable feature to add.

by Aymeric Augustin, 12 years ago

Attachment: 19321.patch added

comment:2 by Aymeric Augustin, 12 years ago

I attached a patch with the general idea.

It'd be nice to make the implementation, tests (and docs if we decide to document this API) consistent between the redirects and locale middleware (#19277).

comment:3 by Ryan Kaskel, 11 years ago

I've applied the patch and added tests in this pull request.

I didn't add docs because of the comments in #19277. Is this still the case here?

comment:4 by Unai Zalakain, 11 years ago

Cc: unai@… added
Has patch: set

comment:5 by Tim Graham, 11 years ago

Needs documentation: set

I think we might as well document these attributes and also include a mention in the release notes.

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

Resolution: fixed
Status: newclosed

In 8b0014869f666b44cd20692e38073ec0a0a8cb08:

Fixed #19321 -- Allowed redirect middleware HTTP responses to be overridden.

Thanks Melevir for the suggestion.

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

In b798d2bf97a48aac1b0a70e9b3d82457a5212123:

Added versionadded annotations for redirect middleware attributes.

refs #19321

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