diff --git a/django/contrib/redirects/middleware.py b/django/contrib/redirects/middleware.py
index 03c9d97..9053c64 100644
a
|
b
|
from django import http
|
8 | 8 | |
9 | 9 | |
10 | 10 | class RedirectFallbackMiddleware(object): |
| 11 | |
| 12 | # Defined as class-level attributes to be subclassing-friendly. |
| 13 | response_gone_class = http.HttpResponseGone |
| 14 | response_redirect_class = http.HttpResponsePermanentRedirect |
| 15 | |
11 | 16 | def __init__(self): |
12 | 17 | if 'django.contrib.sites' not in settings.INSTALLED_APPS: |
13 | 18 | raise ImproperlyConfigured( |
… |
… |
class RedirectFallbackMiddleware(object):
|
16 | 21 | ) |
17 | 22 | |
18 | 23 | def process_response(self, request, response): |
| 24 | # No need to check for a redirect for non-404 responses. |
19 | 25 | if response.status_code != 404: |
20 | | return response # No need to check for a redirect for non-404 responses. |
| 26 | return response |
21 | 27 | |
22 | 28 | full_path = request.get_full_path() |
23 | 29 | current_site = get_current_site(request) |
… |
… |
class RedirectFallbackMiddleware(object):
|
37 | 43 | pass |
38 | 44 | if r is not None: |
39 | 45 | if r.new_path == '': |
40 | | return http.HttpResponseGone() |
41 | | return http.HttpResponsePermanentRedirect(r.new_path) |
| 46 | return self.response_gone_class() |
| 47 | return self.response_redirect_class(r.new_path) |
42 | 48 | |
43 | 49 | # No redirect was found. Return the response. |
44 | 50 | return response |