mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #12945 -- Corrected the parsing of arguments in {% url %} when the argument list has spaces between commas. This is a revised version of r12503, which was a fix for #12072. Thanks to SmileyChris for the patch, and to dmoisset for finding all the places in the docs that the old style syntax was used.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12889 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
273a002544
commit
dafc077e4a
4 changed files with 67 additions and 41 deletions
|
@ -904,7 +904,7 @@ Returns an absolute URL (i.e., a URL without the domain name) matching a given
|
|||
view function and optional parameters. This is a way to output links without
|
||||
violating the DRY principle by having to hard-code URLs in your templates::
|
||||
|
||||
{% url path.to.some_view v1,v2 %}
|
||||
{% url path.to.some_view v1 v2 %}
|
||||
|
||||
The first argument is a path to a view function in the format
|
||||
``package.package.module.function``. Additional arguments are optional and
|
||||
|
@ -912,7 +912,7 @@ should be comma-separated values that will be used as arguments in the URL.
|
|||
The example above shows passing positional arguments. Alternatively you may
|
||||
use keyword syntax::
|
||||
|
||||
{% url path.to.some_view arg1=v1,arg2=v2 %}
|
||||
{% url path.to.some_view arg1=v1 arg2=v2 %}
|
||||
|
||||
Do not mix both positional and keyword syntax in a single call. All arguments
|
||||
required by the URLconf should be present.
|
||||
|
@ -954,7 +954,7 @@ If you'd like to retrieve a URL without displaying it, you can use a slightly
|
|||
different call::
|
||||
|
||||
|
||||
{% url path.to.view arg, arg2 as the_url %}
|
||||
{% url path.to.view arg arg2 as the_url %}
|
||||
|
||||
<a href="{{ the_url }}">I'm linking to {{ the_url }}</a>
|
||||
|
||||
|
@ -976,6 +976,20 @@ This will follow the normal :ref:`namespaced URL resolution strategy
|
|||
<topics-http-reversing-url-namespaces>`, including using any hints provided
|
||||
by the context as to the current application.
|
||||
|
||||
.. versionchanged:: 1.2
|
||||
|
||||
For backwards compatibility, the ``{% url %}`` tag also supports the
|
||||
use of commas to separate arguments. You shouldn't use this in any new
|
||||
projects, but for the sake of the people who are still using it,
|
||||
here's what it looks like::
|
||||
|
||||
{% url path.to.view arg,arg2 %}
|
||||
{% url path.to.view arg, arg2 %}
|
||||
|
||||
This syntax doesn't support the use of literal commas, or or equals
|
||||
signs. Did we mention you shouldn't use this syntax in any new
|
||||
projects?
|
||||
|
||||
.. templatetag:: widthratio
|
||||
|
||||
widthratio
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue