Ticket #16842: django-redirects-querystring.patch
File django-redirects-querystring.patch, 2.4 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/generic_views/base.py
256 256 self.assertEqual(response.status_code, 301) 257 257 self.assertEqual(response['Location'], '/bar/?pork=spam') 258 258 259 def test_include_urlencoded_args(self): 260 "GET arguments can be URL-encoded when included in the redirected URL" 261 response = RedirectView.as_view(url='/bar/', query_string=True)(self.rf.get('/foo/?unicode=%E2%9C%93')) 262 self.assertEqual(response.status_code, 301) 263 self.assertEqual(response['Location'], '/bar/?unicode=%E2%9C%93') 264 259 265 def test_parameter_substitution(self): 260 266 "Redirection URLs can be parameterized" 261 267 response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42) -
django/views/generic/simple.py
48 48 from the request is appended to the URL. 49 49 50 50 """ 51 args = request.META["QUERY_STRING"] 52 if args and query_string and url is not None: 53 url = "%s?%s" % (url, args) 51 if url is not None: 52 url = url % kwargs 53 args = request.META["QUERY_STRING"] 54 if args and query_string: 55 url = "%s?%s" % (url, args) 54 56 55 if url is not None:56 57 klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect 57 return klass(url % kwargs)58 return klass(url) 58 59 else: 59 60 logger.warning('Gone: %s' % request.path, 60 61 extra={ -
django/views/generic/base.py
138 138 are provided as kwargs to this method. 139 139 """ 140 140 if self.url: 141 url = self.url % kwargs 141 142 args = self.request.META["QUERY_STRING"] 142 143 if args and self.query_string: 143 url = "%s?%s" % (self.url, args) 144 else: 145 url = self.url 146 return url % kwargs 144 url = "%s?%s" % (url, args) 145 return url 147 146 else: 148 147 return None 149 148