Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Documented how to handle '%' characters in redirect_to() URL strings …

…(even in

the absence of keyword arguments). Fixed #9773.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9626 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b4364e099e7e61abeaf8efc09a1641fb37ea0d8f 1 parent 80da07e
Malcolm Tredinnick authored December 09, 2008

Showing 1 changed file with 12 additions and 1 deletion. Show diff stats Hide diff stats

  1. 13  docs/ref/generic-views.txt
13  docs/ref/generic-views.txt
@@ -120,7 +120,10 @@ variable ``{{ params.id }}`` that is set to ``15``.
120 120
 Redirects to a given URL.
121 121
 
122 122
 The given URL may contain dictionary-style string formatting, which will be
123  
-interpolated against the parameters captured in the URL.
  123
+interpolated against the parameters captured in the URL. Because keyword
  124
+interpolation is *always* done (even if no arguments are passed in), any ``"%"``
  125
+characters in the URL must be written as ``"%%"`` so that Python will convert
  126
+them to a single percent sign on output.
124 127
 
125 128
 If the given URL is ``None``, Django will return an ``HttpResponseGone`` (410).
126 129
 
@@ -161,6 +164,14 @@ This example returns a 410 HTTP error for requests to ``/bar/``::
161 164
         ('^bar/$', 'redirect_to', {'url': None}),
162 165
     )
163 166
 
  167
+This example shows how ``"%"`` characters must be written in the URL in order
  168
+to avoid confusion with Python's string formatting markers. If the redirect
  169
+string is written as ``"%7Ejacob/"`` (with only a single ``%``), an exception would be raised::
  170
+
  171
+    urlpatterns = patterns('django.views.generic.simple',
  172
+        ('^bar/$', 'redirect_to', {'url': '%%7Ejacob.'}),
  173
+    )
  174
+
164 175
 Date-based generic views
165 176
 ========================
166 177
 

0 notes on commit b4364e0

Please sign in to comment.
Something went wrong with that request. Please try again.