From 1b1060c9168227e9ff4b1e9141ba6086134030bd Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Wed, 20 Apr 2011 19:50:27 +0000 Subject: [PATCH] Fixed #15593 -- Added a note that the output of `reverse` is urlquoted. Thanks to guettli for the report and draft patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16054 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/unicode.txt | 2 ++ docs/topics/http/urls.txt | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt index 2a13736b82..8272e049a8 100644 --- a/docs/ref/unicode.txt +++ b/docs/ref/unicode.txt @@ -140,6 +140,8 @@ Normally, you'll only need to use ``smart_unicode()``. Call it as early as possible on any input data that might be either Unicode or a bytestring, and from then on, you can treat the result as always being Unicode. +.. _uri-and-iri-handling: + URI and IRI handling ~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index 091dcb0007..d721012d3e 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -772,9 +772,9 @@ reverse() If you need to use something similar to the :ttag:`url` template tag in your code, Django provides the following method (in the -``django.core.urlresolvers`` module): +:mod:`django.core.urlresolvers` module): -.. function:: reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None) +.. function:: reverse(viewname, [urlconf=None, args=None, kwargs=None, current_app=None]) ``viewname`` is either the function name (either a function reference, or the string version of the name, if you used that form in ``urlpatterns``) or the @@ -815,6 +815,18 @@ namespaces into URLs on specific application instances, according to the be imported correctly. Do not include lines that reference views you haven't written yet, because those views will not be importable. +.. note:: + + The string returned by :meth:`~django.core.urlresolvers.reverse` is already + :ref:`urlquoted `. For example:: + + >>> reverse('cities', args=u'Orléans') + '.../Orl%C3%A9ans/' + + Applying further encoding (such as :meth:`~django.utils.http.urlquote` or + ``urllib.quote``) to the ouput of :meth:`~django.core.urlresolvers.reverse` + may produce undesirable results. + resolve() ---------