Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#1117 closed enhancement (fixed)

add a standard http response for permanent redirect

Reported by: hugo Owned by: adrian
Component: Internationalization Version:
Severity: trivial Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by hugo)

HttpResponseRedirect uses 302 as it's status code. That's FOUND, not MOVED PERMANTLY - the latter is 301. For that there is no prebuilt response, but it should be added (because in many cases it is much more appropriate to tell the client to use the new URL and forget about the old one). This little patch adds a 301 status code:

Index: utils/
--- utils/       (revision 1779)
+++ utils/       (working copy)
@@ -212,6 +212,12 @@
         self['Location'] = redirect_to
         self.status_code = 302
+class HttpResponsePermanentRedirect(HttpResponse):
+    def __init__(self, redirect_to):
+        HttpResponse.__init__(self)
+        self['Location'] = redirect_to
+        self.status_code = 301
 class HttpResponseNotModified(HttpResponse):
     def __init__(self):

Situations where we do fixed redirects - for example those done by the CommonMiddleware - should actually use 301 instead of 302.

Change History (3)

comment:1 Changed 10 years ago by hugo

  • Description modified (diff)

comment:2 Changed 10 years ago by adrian

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

(In [1816]) Fixed #1117 -- Added HttpResponsePermanentRedirect

comment:3 Changed 10 years ago by anonymous

  • Component changed from Core framework to Internationalization
  • priority changed from normal to high
  • Severity changed from normal to trivial
  • Type changed from defect to enhancement
Note: See TracTickets for help on using tickets.
Back to Top