diff --git a/django/views/generic/base.py b/django/views/generic/base.py index f2c6d3f9f5..ef74474417 100644 --- a/django/views/generic/base.py +++ b/django/views/generic/base.py @@ -161,3 +161,18 @@ class RedirectView(View): 'request': self.request }) return http.HttpResponseGone() + + def head(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) + + def post(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) + + def options(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) + + def delete(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) + + def put(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py index e20932b7fe..4003bbe732 100644 --- a/tests/regressiontests/generic_views/base.py +++ b/tests/regressiontests/generic_views/base.py @@ -261,3 +261,33 @@ class RedirectViewTest(unittest.TestCase): response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42) self.assertEqual(response.status_code, 301) self.assertEqual(response['Location'], '/bar/42/') + + def test_redirect_POST(self): + "Default is a permanent redirect" + response = RedirectView.as_view(url='/bar/')(self.rf.post('/foo/')) + self.assertEqual(response.status_code, 301) + self.assertEqual(response['Location'], '/bar/') + + def test_redirect_HEAD(self): + "Default is a permanent redirect" + response = RedirectView.as_view(url='/bar/')(self.rf.head('/foo/')) + self.assertEqual(response.status_code, 301) + self.assertEqual(response['Location'], '/bar/') + + def test_redirect_OPTIONS(self): + "Default is a permanent redirect" + response = RedirectView.as_view(url='/bar/')(self.rf.options('/foo/')) + self.assertEqual(response.status_code, 301) + self.assertEqual(response['Location'], '/bar/') + + def test_redirect_PUT(self): + "Default is a permanent redirect" + response = RedirectView.as_view(url='/bar/')(self.rf.put('/foo/')) + self.assertEqual(response.status_code, 301) + self.assertEqual(response['Location'], '/bar/') + + def test_redirect_DELETE(self): + "Default is a permanent redirect" + response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/')) + self.assertEqual(response.status_code, 301) + self.assertEqual(response['Location'], '/bar/')