Ticket #16842: 16842-3.diff

File 16842-3.diff, 1.7 KB (added by Claude Paroz, 12 years ago)

Patch updated to current trunk

  • django/views/generic/base.py

    diff --git a/django/views/generic/base.py b/django/views/generic/base.py
    index 6dfbc7a..fcdc7c7 100644
    a b class RedirectView(View):  
    139139        are provided as kwargs to this method.
    140140        """
    141141        if self.url:
     142            url = self.url % kwargs
    142143            args = self.request.META.get('QUERY_STRING', '')
    143144            if args and self.query_string:
    144                 url = "%s?%s" % (self.url, args)
    145             else:
    146                 url = self.url
    147             return url % kwargs
     145                url = "%s?%s" % (url, args)
     146            return url
    148147        else:
    149148            return None
    150149
  • tests/regressiontests/generic_views/base.py

    diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py
    index e7aeaf9..6528dc6 100644
    a b class RedirectViewTest(unittest.TestCase):  
    283283        self.assertEqual(response.status_code, 301)
    284284        self.assertEqual(response['Location'], '/bar/?pork=spam')
    285285
     286    def test_include_urlencoded_args(self):
     287        "GET arguments can be URL-encoded when included in the redirected URL"
     288        response = RedirectView.as_view(url='/bar/', query_string=True)(
     289            self.rf.get('/foo/?unicode=%E2%9C%93'))
     290        self.assertEqual(response.status_code, 301)
     291        self.assertEqual(response['Location'], '/bar/?unicode=%E2%9C%93')
     292
    286293    def test_parameter_substitution(self):
    287294        "Redirection URLs can be parameterized"
    288295        response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42)
Back to Top