Ticket #18037: 18037-1.diff

File 18037-1.diff, 61.3 KB (added by Claude Paroz, 13 years ago)

Remove old-style url and ssi template tags

  • django/contrib/admin/templates/admin/500.html

    diff --git a/django/contrib/admin/templates/admin/500.html b/django/contrib/admin/templates/admin/500.html
    index eeb9e8d..9a3b636 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/admin/app_index.html

    diff --git a/django/contrib/admin/templates/admin/app_index.html b/django/contrib/admin/templates/admin/app_index.html
    index 4616b16..9f65357 100644
    a b  
    11{% extends "admin/index.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% if not is_popup %}
    65{% block breadcrumbs %}
  • django/contrib/admin/templates/admin/auth/user/change_password.html

    diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html
    index 6adfaed..4fdccd1 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n admin_static admin_modify %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block extrahead %}{{ block.super }}
  • django/contrib/admin/templates/admin/base.html

    diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
    index 3b50adc..6e2de51 100644
    a b  
    1 {% load admin_static %}{% load url from future %}<!DOCTYPE html>
     1{% load admin_static %}<!DOCTYPE html>
    22<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
    33<head>
    44<title>{% block title %}{% endblock %}</title>
  • django/contrib/admin/templates/admin/change_form.html

    diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html
    index de44298..79c4f1b 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n admin_static admin_modify %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block extrahead %}{{ block.super }}
  • django/contrib/admin/templates/admin/change_list.html

    diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html
    index 98869cf..3c73ac8 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n admin_static admin_list %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block extrastyle %}
  • django/contrib/admin/templates/admin/delete_confirmation.html

    diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html
    index 43440b2..71d3eb9 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block breadcrumbs %}
  • django/contrib/admin/templates/admin/delete_selected_confirmation.html

    diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
    index 3120cc5..608052d 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n l10n %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block breadcrumbs %}
  • django/contrib/admin/templates/admin/invalid_setup.html

    diff --git a/django/contrib/admin/templates/admin/invalid_setup.html b/django/contrib/admin/templates/admin/invalid_setup.html
    index c2df4df..7c71107 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/admin/login.html

    diff --git a/django/contrib/admin/templates/admin/login.html b/django/contrib/admin/templates/admin/login.html
    index c008957..06fe4c8 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n admin_static %}
    3 {% load url from future %}
    43
    54{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
    65
  • django/contrib/admin/templates/admin/object_history.html

    diff --git a/django/contrib/admin/templates/admin/object_history.html b/django/contrib/admin/templates/admin/object_history.html
    index ebd1960..2c35337 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43{% load admin_urls %}
    54
    65{% block breadcrumbs %}
  • django/contrib/admin/templates/registration/logged_out.html

    diff --git a/django/contrib/admin/templates/registration/logged_out.html b/django/contrib/admin/templates/registration/logged_out.html
    index e95d864..6a18186 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></div>{% endblock %}
    65
  • django/contrib/admin/templates/registration/password_change_done.html

    diff --git a/django/contrib/admin/templates/registration/password_change_done.html b/django/contrib/admin/templates/registration/password_change_done.html
    index 863fc96..1c928a0 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}{% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/registration/password_change_form.html

    diff --git a/django/contrib/admin/templates/registration/password_change_form.html b/django/contrib/admin/templates/registration/password_change_form.html
    index ea8abb4..5cb3473 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n static %}
    3 {% load url from future %}
    43{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
    54{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %} {% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
    65{% block breadcrumbs %}
  • django/contrib/admin/templates/registration/password_reset_complete.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_complete.html b/django/contrib/admin/templates/registration/password_reset_complete.html
    index 7c07707..d97f338 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/registration/password_reset_confirm.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_confirm.html b/django/contrib/admin/templates/registration/password_reset_confirm.html
    index d5299eb..81020b9 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/registration/password_reset_done.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_done.html b/django/contrib/admin/templates/registration/password_reset_done.html
    index fd73af8..3c9796e 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admin/templates/registration/password_reset_email.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_email.html b/django/contrib/admin/templates/registration/password_reset_email.html
    index de9dc79..4f002fe 100644
    a b  
    1 {% load i18n %}{% load url from future %}{% autoescape off %}
     1{% load i18n %}{% autoescape off %}
    22{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
    33
    44{% trans "Please go to the following page and choose a new password:" %}
  • django/contrib/admin/templates/registration/password_reset_form.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_form.html b/django/contrib/admin/templates/registration/password_reset_form.html
    index 2b591fe..ca9ff11 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/bookmarklets.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/bookmarklets.html b/django/contrib/admindocs/templates/admin_doc/bookmarklets.html
    index baa717c..cde2854 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/index.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/index.html b/django/contrib/admindocs/templates/admin_doc/index.html
    index 652fbfd..5347341 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/missing_docutils.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/missing_docutils.html b/django/contrib/admindocs/templates/admin_doc/missing_docutils.html
    index 6843bab..f8a68ce 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/model_detail.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/model_detail.html b/django/contrib/admindocs/templates/admin_doc/model_detail.html
    index 82cb405..9fb4eee 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block extrahead %}
    65{{ block.super }}
  • django/contrib/admindocs/templates/admin_doc/model_index.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/model_index.html b/django/contrib/admindocs/templates/admin_doc/model_index.html
    index 4eb3cf6..7a8c699 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block coltype %}colSM{% endblock %}
    65
  • django/contrib/admindocs/templates/admin_doc/template_detail.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/template_detail.html b/django/contrib/admindocs/templates/admin_doc/template_detail.html
    index 307dd62..27fca28 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/template_filter_index.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/template_filter_index.html b/django/contrib/admindocs/templates/admin_doc/template_filter_index.html
    index 1809bc9..1878e80 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block coltype %}colSM{% endblock %}
    65{% block breadcrumbs %}
  • django/contrib/admindocs/templates/admin_doc/template_tag_index.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/template_tag_index.html b/django/contrib/admindocs/templates/admin_doc/template_tag_index.html
    index 18e5d95..568b118 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block coltype %}colSM{% endblock %}
    65{% block breadcrumbs %}
  • django/contrib/admindocs/templates/admin_doc/view_detail.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/view_detail.html b/django/contrib/admindocs/templates/admin_doc/view_detail.html
    index 41c8121..efe5fed 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block breadcrumbs %}
    65<div class="breadcrumbs">
  • django/contrib/admindocs/templates/admin_doc/view_index.html

    diff --git a/django/contrib/admindocs/templates/admin_doc/view_index.html b/django/contrib/admindocs/templates/admin_doc/view_index.html
    index e508c84..86342c6 100644
    a b  
    11{% extends "admin/base_site.html" %}
    22{% load i18n %}
    3 {% load url from future %}
    43
    54{% block coltype %}colSM{% endblock %}
    65{% block breadcrumbs %}
  • django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html

    diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
    index 5df2a34..aa7f784 100644
    a b  
    1 {% load url from future %}unicode: {{ user }}
     1unicode: {{ user }}
    22id: {{ user.id }}
    33username: {{ user.username }}
    44url: {% url 'userpage' user %}
  • django/template/defaulttags.py

    diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
    index 954c5d6..f0a83d7 100644
    a b def include_is_allowed(filepath):  
    315315    return False
    316316
    317317class SsiNode(Node):
    318     def __init__(self, filepath, parsed, legacy_filepath=True):
     318    def __init__(self, filepath, parsed):
    319319        self.filepath = filepath
    320320        self.parsed = parsed
    321         self.legacy_filepath = legacy_filepath
    322321
    323322    def render(self, context):
    324         filepath = self.filepath
    325         if not self.legacy_filepath:
    326             filepath = filepath.resolve(context)
     323        filepath = self.filepath.resolve(context)
    327324
    328325        if not include_is_allowed(filepath):
    329326            if settings.DEBUG:
    class TemplateTagNode(Node):  
    385382        return self.mapping.get(self.tagtype, '')
    386383
    387384class URLNode(Node):
    388     def __init__(self, view_name, args, kwargs, asvar, legacy_view_name=True):
     385    def __init__(self, view_name, args, kwargs, asvar):
    389386        self.view_name = view_name
    390         self.legacy_view_name = legacy_view_name
    391387        self.args = args
    392388        self.kwargs = kwargs
    393389        self.asvar = asvar
    class URLNode(Node):  
    398394        kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context))
    399395                       for k, v in self.kwargs.items()])
    400396
    401         view_name = self.view_name
    402         if not self.legacy_view_name:
    403             view_name = view_name.resolve(context)
     397        view_name = self.view_name.resolve(context)
    404398
    405399        # Try to look up the URL twice: once given the view name, and again
    406400        # relative to what we guess is the "main" app. If they both fail,
    def ssi(parser, token):  
    969963    of another file -- which must be specified using an absolute path --
    970964    in the current page::
    971965
    972         {% ssi /home/html/ljworld.com/includes/right_generic.html %}
     966        {% ssi "/home/html/ljworld.com/includes/right_generic.html" %}
    973967
    974968    If the optional "parsed" parameter is given, the contents of the included
    975969    file are evaluated as template code, with the current context::
    976970
    977         {% ssi /home/html/ljworld.com/includes/right_generic.html parsed %}
     971        {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
    978972    """
    979 
    980     import warnings
    981     warnings.warn('The syntax for the ssi template tag is changing. Load the `ssi` tag from the `future` tag library to start using the new behavior.',
    982                   category=DeprecationWarning)
    983 
    984     bits = token.contents.split()
     973    bits = token.split_contents()
    985974    parsed = False
    986975    if len(bits) not in (2, 3):
    987976        raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
    def ssi(parser, token):  
    992981        else:
    993982            raise TemplateSyntaxError("Second (optional) argument to %s tag"
    994983                                      " must be 'parsed'" % bits[0])
    995     return SsiNode(bits[1], parsed, legacy_filepath=True)
     984    filepath = parser.compile_filter(bits[1])
     985    return SsiNode(filepath, parsed)
    996986
    997987@register.tag
    998988def load(parser, token):
    def url(parser, token):  
    12011191    This is a way to define links that aren't tied to a particular URL
    12021192    configuration::
    12031193
    1204         {% url path.to.some_view arg1 arg2 %}
     1194        {% url "path.to.some_view" arg1 arg2 %}
    12051195
    12061196        or
    12071197
    1208         {% url path.to.some_view name1=value1 name2=value2 %}
     1198        {% url "path.to.some_view" name1=value1 name2=value2 %}
    12091199
    1210     The first argument is a path to a view. It can be an absolute python path
     1200    The first argument is a path to a view. It can be an absolute Python path
    12111201    or just ``app_name.view_name`` without the project name if the view is
    1212     located inside the project.  Other arguments are comma-separated values
    1213     that will be filled in place of positional and keyword arguments in the
    1214     URL. All arguments for the URL should be present.
     1202    located inside the project.
     1203
     1204    Other arguments are space-separated values that will be filled in place of
     1205    positional and keyword arguments in the URL. Don't mix positional and
     1206    keyword arguments.
     1207
     1208    All arguments for the URL should be present.
    12151209
    12161210    For example if you have a view ``app_name.client`` taking client's id and
    12171211    the corresponding line in a URLconf looks like this::
    def url(parser, token):  
    12251219
    12261220    then in a template you can create a link for a certain client like this::
    12271221
    1228         {% url app_name.client client.id %}
     1222        {% url "app_name.client" client.id %}
    12291223
    12301224    The URL will look like ``/clients/client/123/``.
    1231     """
    12321225
    1233     import warnings
    1234     warnings.warn('The syntax for the url template tag is changing. Load the `url` tag from the `future` tag library to start using the new behavior.',
    1235                   category=DeprecationWarning)
     1226    The first argument can also be a named URL instead of the Python path to
     1227    the view callable. For example if the URLconf entry looks like this::
     1228
     1229        url('^client/(\d+)/$', name='client-detail-view')
     1230
     1231    then in the template you can use::
     1232
     1233        {% url "client-detail-view" client.id %}
    12361234
     1235    There is even another possible value type for the first argument. It can be
     1236    the name of a template variable that will be evaluated to obtain the view
     1237    name or the URL name, e.g.::
     1238
     1239        {% with view_path="app_name.client" %}
     1240        {% url view_path client.id %}
     1241        {% endwith %}
     1242
     1243        or,
     1244
     1245        {% with url_name="client-detail-view" %}
     1246        {% url url_name client.id %}
     1247        {% endwith %}
     1248
     1249    """
    12371250    bits = token.split_contents()
    12381251    if len(bits) < 2:
    12391252        raise TemplateSyntaxError("'%s' takes at least one argument"
    12401253                                  " (path to a view)" % bits[0])
    1241     viewname = bits[1]
     1254    viewname = parser.compile_filter(bits[1])
    12421255    args = []
    12431256    kwargs = {}
    12441257    asvar = None
    def url(parser, token):  
    12471260        asvar = bits[-1]
    12481261        bits = bits[:-2]
    12491262
    1250     # Backwards compatibility: check for the old comma separated format
    1251     # {% url urlname arg1,arg2 %}
    1252     # Initial check - that the first space separated bit has a comma in it
    1253     if bits and ',' in bits[0]:
    1254         check_old_format = True
    1255         # In order to *really* be old format, there must be a comma
    1256         # in *every* space separated bit, except the last.
    1257         for bit in bits[1:-1]:
    1258             if ',' not in bit:
    1259                 # No comma in this bit. Either the comma we found
    1260                 # in bit 1 was a false positive (e.g., comma in a string),
    1261                 # or there is a syntax problem with missing commas
    1262                 check_old_format = False
    1263                 break
    1264     else:
    1265         # No comma found - must be new format.
    1266         check_old_format = False
    1267 
    1268     if check_old_format:
    1269         # Confirm that this is old format by trying to parse the first
    1270         # argument. An exception will be raised if the comma is
    1271         # unexpected (i.e. outside of a static string).
    1272         match = kwarg_re.match(bits[0])
    1273         if match:
    1274             value = match.groups()[1]
    1275             try:
    1276                 parser.compile_filter(value)
    1277             except TemplateSyntaxError:
    1278                 bits = ''.join(bits).split(',')
    1279 
    1280     # Now all the bits are parsed into new format,
    1281     # process them as template vars
    12821263    if len(bits):
    12831264        for bit in bits:
    12841265            match = kwarg_re.match(bit)
    def url(parser, token):  
    12901271            else:
    12911272                args.append(parser.compile_filter(value))
    12921273
    1293     return URLNode(viewname, args, kwargs, asvar, legacy_view_name=True)
     1274    return URLNode(viewname, args, kwargs, asvar)
    12941275
    12951276@register.tag
    12961277def widthratio(parser, token):
  • django/templatetags/future.py

    diff --git a/django/templatetags/future.py b/django/templatetags/future.py
    index 9fb2d11..b9327fa 100644
    a b  
    1 from django.template import Library, TemplateSyntaxError
    2 from django.template.defaulttags import kwarg_re, SsiNode, URLNode
     1from django.template import Library
     2from django.template.defaulttags import url as default_url, ssi as default_ssi
    33
    44register = Library()
    55
    66@register.tag
    77def ssi(parser, token):
    8     """
    9     Outputs the contents of a given file into the page.
    10 
    11     Like a simple "include" tag, the ``ssi`` tag includes the contents
    12     of another file -- which must be specified using an absolute path --
    13     in the current page::
    14 
    15         {% ssi "/home/html/ljworld.com/includes/right_generic.html" %}
    16 
    17     If the optional "parsed" parameter is given, the contents of the included
    18     file are evaluated as template code, with the current context::
    19 
    20         {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
    21     """
    22     bits = token.split_contents()
    23     parsed = False
    24     if len(bits) not in (2, 3):
    25         raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
    26                                   " the file to be included")
    27     if len(bits) == 3:
    28         if bits[2] == 'parsed':
    29             parsed = True
    30         else:
    31             raise TemplateSyntaxError("Second (optional) argument to %s tag"
    32                                       " must be 'parsed'" % bits[0])
    33     filepath = parser.compile_filter(bits[1])
    34     return SsiNode(filepath, parsed, legacy_filepath=False)
     8    return default_ssi(parser, token)
    359
    3610@register.tag
    3711def url(parser, token):
    38     """
    39     Returns an absolute URL matching given view with its parameters.
    40 
    41     This is a way to define links that aren't tied to a particular URL
    42     configuration::
    43 
    44         {% url "path.to.some_view" arg1 arg2 %}
    45 
    46         or
    47 
    48         {% url "path.to.some_view" name1=value1 name2=value2 %}
    49 
    50     The first argument is a path to a view. It can be an absolute Python path
    51     or just ``app_name.view_name`` without the project name if the view is
    52     located inside the project.
    53 
    54     Other arguments are space-separated values that will be filled in place of
    55     positional and keyword arguments in the URL. Don't mix positional and
    56     keyword arguments.
    57 
    58     All arguments for the URL should be present.
    59 
    60     For example if you have a view ``app_name.client`` taking client's id and
    61     the corresponding line in a URLconf looks like this::
    62 
    63         ('^client/(\d+)/$', 'app_name.client')
    64 
    65     and this app's URLconf is included into the project's URLconf under some
    66     path::
    67 
    68         ('^clients/', include('project_name.app_name.urls'))
    69 
    70     then in a template you can create a link for a certain client like this::
    71 
    72         {% url "app_name.client" client.id %}
    73 
    74     The URL will look like ``/clients/client/123/``.
    75 
    76     The first argument can also be a named URL instead of the Python path to
    77     the view callable. For example if the URLconf entry looks like this::
    78 
    79         url('^client/(\d+)/$', name='client-detail-view')
    80 
    81     then in the template you can use::
    82 
    83         {% url "client-detail-view" client.id %}
    84 
    85     There is even another possible value type for the first argument. It can be
    86     the name of a template variable that will be evaluated to obtain the view
    87     name or the URL name, e.g.::
    88 
    89         {% with view_path="app_name.client" %}
    90         {% url view_path client.id %}
    91         {% endwith %}
    92 
    93         or,
    94 
    95         {% with url_name="client-detail-view" %}
    96         {% url url_name client.id %}
    97         {% endwith %}
    98 
    99     """
    100     bits = token.split_contents()
    101     if len(bits) < 2:
    102         raise TemplateSyntaxError("'%s' takes at least one argument"
    103                                   " (path to a view)" % bits[0])
    104     viewname = parser.compile_filter(bits[1])
    105     args = []
    106     kwargs = {}
    107     asvar = None
    108     bits = bits[2:]
    109     if len(bits) >= 2 and bits[-2] == 'as':
    110         asvar = bits[-1]
    111         bits = bits[:-2]
    112 
    113     if len(bits):
    114         for bit in bits:
    115             match = kwarg_re.match(bit)
    116             if not match:
    117                 raise TemplateSyntaxError("Malformed arguments to url tag")
    118             name, value = match.groups()
    119             if name:
    120                 kwargs[name] = parser.compile_filter(value)
    121             else:
    122                 args.append(parser.compile_filter(value))
    123 
    124     return URLNode(viewname, args, kwargs, asvar, legacy_view_name=False)
     12    return default_url(parser, token)
  • docs/ref/contrib/admin/index.txt

    diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
    index 3c94150..779b22a 100644
    a b To allow easier reversing of the admin urls in templates, Django provides an  
    20302030.. code-block:: html+django
    20312031
    20322032    {% load admin_urls %}
    2033     {% load url from future %}
    20342033    <a href="{% url opts|admin_urlname:'add' %}">Add user</a>
    20352034    <a href="{% url opts|admin_urlname:'delete' user.pk %}">Delete this user</a>
    20362035
  • docs/ref/templates/builtins.txt

    diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
    index 0251dcb..5019963 100644
    a b Like a simple :ttag:`include` tag, ``{% ssi %}`` includes the contents of  
    941941another file -- which must be specified using an absolute path -- in the
    942942current page::
    943943
    944     {% ssi /home/html/ljworld.com/includes/right_generic.html %}
     944    {% ssi '/home/html/ljworld.com/includes/right_generic.html' %}
     945
     946The first parameter of ``ssi`` can be a quoted literal or any other context
     947variable.
    945948
    946949If the optional "parsed" parameter is given, the contents of the included
    947950file are evaluated as template code, within the current context::
    948951
    949     {% ssi /home/html/ljworld.com/includes/right_generic.html parsed %}
     952    {% ssi '/home/html/ljworld.com/includes/right_generic.html' parsed %}
    950953
    951954Note that if you use ``{% ssi %}``, you'll need to define
    952955:setting:`ALLOWED_INCLUDE_ROOTS` in your Django settings, as a security
    measure.  
    954957
    955958See also: :ttag:`{% include %}<include>`.
    956959
    957 .. admonition:: Forwards compatibility
    958 
    959     .. versionchanged:: 1.3
    960 
    961     In Django 1.5, the behavior of the :ttag:`ssi` template tag will
    962     change, with the first argument being made into a context
    963     variable, rather than being a special case unquoted constant. This
    964     will allow the :ttag:`ssi` tag to use a context variable as the
    965     value of the page to be included.
    966 
    967     In order to provide a forwards compatibility path, Django 1.3
    968     provides a future compatibility library -- ``future`` -- that
    969     implements the new behavior. To use this library, add a
    970     :ttag:`load` call at the top of any template using the :ttag:`ssi`
    971     tag, and wrap the first argument to the :ttag:`ssi` tag in quotes.
    972     For example::
    973 
    974         {% load ssi from future %}
    975         {% ssi '/home/html/ljworld.com/includes/right_generic.html' %}
    976 
    977     In Django 1.5, the unquoted constant behavior will be replaced
    978     with the behavior provided by the ``future`` tag library.
    979     Existing templates should be migrated to use the new syntax.
    980 
    981960.. templatetag:: templatetag
    982961
    983962templatetag
    given view function and optional parameters. This is a way to output links  
    1013992without violating the DRY principle by having to hard-code URLs in your
    1014993templates::
    1015994
    1016     {% url path.to.some_view v1 v2 %}
     995    {% url 'path.to.some_view' v1 v2 %}
    1017996
    1018997The first argument is a path to a view function in the format
    1019 ``package.package.module.function``. Additional arguments are optional and
     998``package.package.module.function``. It can be a quoted literal or any other
     999context variable. Additional arguments are optional and
    10201000should be space-separated values that will be used as arguments in the URL.
    10211001The example above shows passing positional arguments. Alternatively you may
    10221002use keyword syntax::
    10231003
    1024     {% url path.to.some_view arg1=v1 arg2=v2 %}
     1004    {% url 'path.to.some_view' arg1=v1 arg2=v2 %}
    10251005
    10261006Do not mix both positional and keyword syntax in a single call. All arguments
    10271007required by the URLconf should be present.
    such as this:  
    10431023
    10441024...then, in a template, you can create a link to this view like this::
    10451025
    1046     {% url app_views.client client.id %}
     1026    {% url 'app_views.client' client.id %}
    10471027
    10481028The template tag will output the string ``/clients/client/123/``.
    10491029
    If you'd like to retrieve a URL without displaying it, you can use a slightly  
    10591039different call::
    10601040
    10611041
    1062     {% url path.to.view arg arg2 as the_url %}
     1042    {% url 'path.to.view' arg arg2 as the_url %}
    10631043
    10641044    <a href="{{ the_url }}">I'm linking to {{ the_url }}</a>
    10651045
    10661046This ``{% url ... as var %}`` syntax will *not* cause an error if the view is
    10671047missing. In practice you'll use this to link to views that are optional::
    10681048
    1069     {% url path.to.view as the_url %}
     1049    {% url 'path.to.view' as the_url %}
    10701050    {% if the_url %}
    10711051      <a href="{{ the_url }}">Link to optional stuff</a>
    10721052    {% endif %}
    10731053
    10741054If you'd like to retrieve a namespaced URL, specify the fully qualified name::
    10751055
    1076     {% url myapp:view-name %}
     1056    {% url 'myapp:view-name' %}
    10771057
    10781058This will follow the normal :ref:`namespaced URL resolution strategy
    10791059<topics-http-reversing-url-namespaces>`, including using any hints provided
    10801060by the context as to the current application.
    10811061
    1082 .. versionchanged:: 1.2
    1083 
    1084 For backwards compatibility, the ``{% url %}`` tag also supports the
    1085 use of commas to separate arguments. You shouldn't use this in any new
    1086 projects, but for the sake of the people who are still using it,
    1087 here's what it looks like::
    1088 
    1089     {% url path.to.view arg,arg2 %}
    1090     {% url path.to.view arg, arg2 %}
    1091 
    1092 This syntax doesn't support the use of literal commas, or equals
    1093 signs. Did we mention you shouldn't use this syntax in any new
    1094 projects?
    1095 
    1096 .. admonition:: Forwards compatibility
    1097 
    1098     .. versionchanged:: 1.3
    1099 
    1100     In Django 1.5, the behavior of the :ttag:`url` template tag will
    1101     change, with the first argument being made into a context
    1102     variable, rather than being a special case unquoted constant. This
    1103     will allow the :ttag:`url` tag to use a context variable as the
    1104     value of the URL name to be reversed.
    1105 
    1106     In order to provide a forwards compatibility path, Django 1.3
    1107     provides a future compatibility library -- ``future`` -- that
    1108     implements the new behavior. To use this library, add a
    1109     :ttag:`load` call at the top of any template using the :ttag:`url`
    1110     tag, and wrap the first argument to the :ttag:`url` tag in quotes.
    1111     For example::
    1112 
    1113         {% load url from future %}
    1114 
    1115 
    1116         {% url 'app_views.client' %}
    1117 
    1118         {% url 'myapp:view-name' %}
    1119 
    1120         {% with view_path="app_views.client" %}
    1121         {% url view_path client.id %}
    1122         {% endwith %}
    1123 
    1124         {% with url_name="client-detail-view" %}
    1125         {% url url_name client.id %}
    1126         {% endwith %}
    1127 
    1128     The new library also drops support for the comma syntax for
    1129     separating arguments to the :ttag:`url` template tag.
    1130 
    1131     In Django 1.5, the old behavior will be replaced with the behavior
    1132     provided by the ``future`` tag library. Existing templates be
    1133     migrated to use the new syntax.
    1134 
    11351062.. templatetag:: widthratio
    11361063
    11371064widthratio
  • docs/topics/auth.txt

    diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
    index 1e73abd..12adda8 100644
    a b The login_required decorator  
    10141014    .. code-block:: html+django
    10151015
    10161016        {% extends "base.html" %}
    1017         {% load url from future %}
    10181017
    10191018        {% block content %}
    10201019
    includes a few other useful built-in views located in  
    12361235
    12371236    .. code-block:: html+django
    12381237
    1239         {% load url from future %}
    12401238        Someone asked for password reset for email {{ email }}. Follow the link below:
    12411239        {{ protocol}}://{{ site_name }}{% url 'auth_password_reset_confirm' uidb36=uid token=token %}
    12421240
  • docs/topics/i18n/timezones.txt

    diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt
    index e5453ef..1f4792a 100644
    a b Include a form in ``template.html`` that will ``POST`` to this view:  
    208208
    209209.. code-block:: html+django
    210210
    211     {% load tz %}{% load url from future %}
     211    {% load tz %}
    212212    <form action="{% url 'set_timezone' %}" method="POST">
    213213        {% csrf_token %}
    214214        <label for="timezone">Time zone:</label>
  • tests/regressiontests/i18n/patterns/tests.py

    diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py
    index d8ca3ac..e59994a 100644
    a b class URLTagTests(URLTestCaseBase):  
    243243    """
    244244    Test if the language tag works.
    245245    """
    246     def setUp(self):
    247         self.save_warnings_state()
    248         warnings.filterwarnings('ignore', category=DeprecationWarning,
    249                                 module='django.template.defaulttags')
    250 
    251     def tearDown(self):
    252         self.restore_warnings_state()
    253 
    254246    def test_strings_only(self):
    255247        t = Template("""{% load i18n %}
    256             {% language 'nl' %}{% url no-prefix-translated %}{% endlanguage %}
    257             {% language 'pt-br' %}{% url no-prefix-translated %}{% endlanguage %}""")
     248            {% language 'nl' %}{% url 'no-prefix-translated' %}{% endlanguage %}
     249            {% language 'pt-br' %}{% url 'no-prefix-translated' %}{% endlanguage %}""")
    258250        self.assertEqual(t.render(Context({})).strip().split(),
    259251                         [u'/vertaald/', u'/traduzidos/'])
    260252
    261253    def test_context(self):
    262254        ctx = Context({'lang1':'nl', 'lang2':'pt-br'})
    263255        tpl = Template("""{% load i18n %}
    264             {% language lang1 %}{% url no-prefix-translated %}{% endlanguage %}
    265             {% language lang2 %}{% url no-prefix-translated %}{% endlanguage %}""")
     256            {% language lang1 %}{% url 'no-prefix-translated' %}{% endlanguage %}
     257            {% language lang2 %}{% url 'no-prefix-translated' %}{% endlanguage %}""")
    266258        self.assertEqual(tpl.render(ctx).strip().split(),
    267259                         [u'/vertaald/', u'/traduzidos/'])
    268260
    269261    def test_args(self):
    270262        tpl = Template("""{% load i18n %}
    271             {% language 'nl' %}{% url no-prefix-translated-slug 'apo' %}{% endlanguage %}
    272             {% language 'pt-br' %}{% url no-prefix-translated-slug 'apo' %}{% endlanguage %}""")
     263            {% language 'nl' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
     264            {% language 'pt-br' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}""")
    273265        self.assertEqual(tpl.render(Context({})).strip().split(),
    274266                         [u'/vertaald/apo/', u'/traduzidos/apo/'])
    275267
    276268    def test_kwargs(self):
    277269        tpl = Template("""{% load i18n %}
    278             {% language 'nl'  %}{% url no-prefix-translated-slug slug='apo' %}{% endlanguage %}
    279             {% language 'pt-br' %}{% url no-prefix-translated-slug slug='apo' %}{% endlanguage %}""")
    280         self.assertEqual(tpl.render(Context({})).strip().split(),
    281                          [u'/vertaald/apo/', u'/traduzidos/apo/'])
    282 
    283     def test_future_kwargs(self):
    284         tpl = Template("""{% load i18n %}{% load url from future %}
    285270            {% language 'nl'  %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
    286271            {% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}""")
    287272        self.assertEqual(tpl.render(Context({})).strip().split(),
  • tests/regressiontests/templates/templates/response.html

    diff --git a/tests/regressiontests/templates/templates/response.html b/tests/regressiontests/templates/templates/response.html
    index 7535fa7..96ab97f 100644
    a b  
    1 {% load url from future %}This is where you can find the snark: {% url "snark" %}
    2 {% now "U.u" %}
    3  No newline at end of file
     1This is where you can find the snark: {% url "snark" %}
     2{% now "U.u" %}
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index e166f7e..66cc611 100644
    a b class Templates(unittest.TestCase):  
    14111411            ### SSI TAG ########################################################
    14121412
    14131413            # Test normal behavior
    1414             'old-ssi01': ('{%% ssi %s %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
    1415             'old-ssi02': ('{%% ssi %s %%}' % os.path.join(basedir, 'not_here'), {}, ''),
    1416 
    1417             # Test parsed output
    1418             'old-ssi06': ('{%% ssi %s parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
    1419             'old-ssi07': ('{%% ssi %s parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
    1420 
    1421             # Test space in file name
    1422             'old-ssi08': ('{%% ssi %s %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {}, template.TemplateSyntaxError),
    1423             'old-ssi09': ('{%% ssi %s parsed %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {'test': 'Look ma! It parsed!'}, template.TemplateSyntaxError),
    1424 
    1425             # Future compatibility
    1426             # Test normal behavior
    1427             'ssi01': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
    1428             'ssi02': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'not_here'), {}, ''),
    1429             'ssi03': ("{%% load ssi from future %%}{%% ssi '%s' %%}" % os.path.join(basedir, 'not_here'), {}, ''),
     1414            'ssi01': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
     1415            'ssi02': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'not_here'), {}, ''),
     1416            'ssi03': ("{%% ssi '%s' %%}" % os.path.join(basedir, 'not_here'), {}, ''),
    14301417
    14311418            # Test passing as a variable
    14321419            'ssi04': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': os.path.join(basedir, 'templates', 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'),
    14331420            'ssi05': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': 'no_file'}, ''),
    14341421
    14351422            # Test parsed output
    1436             'ssi06': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
    1437             'ssi07': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
     1423            'ssi06': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
     1424            'ssi07': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
    14381425
    14391426            # Test space in file name
    1440             'ssi08': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {}, 'This is for testing an ssi include with spaces in its name. {{ test }}\n'),
    1441             'ssi09': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include with spaces in its name. Look ma! It parsed!\n'),
     1427            'ssi08': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {}, 'This is for testing an ssi include with spaces in its name. {{ test }}\n'),
     1428            'ssi09': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include with spaces in its name. Look ma! It parsed!\n'),
    14421429
    14431430            ### TEMPLATETAG TAG #######################################################
    14441431            'templatetag01': ('{% templatetag openblock %}', {}, '{%'),
    class Templates(unittest.TestCase):  
    15091496
    15101497            ### URL TAG ########################################################
    15111498            # Successes
    1512             'legacyurl02': ('{% url regressiontests.templates.views.client_action id=client.id,action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1513             'legacyurl02a': ('{% url regressiontests.templates.views.client_action client.id,"update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1514             'legacyurl02b': ("{% url regressiontests.templates.views.client_action id=client.id,action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1515             'legacyurl02c': ("{% url regressiontests.templates.views.client_action client.id,'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1516             'legacyurl10': ('{% url regressiontests.templates.views.client_action id=client.id,action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'),
    1517             'legacyurl13': ('{% url regressiontests.templates.views.client_action id=client.id, action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1518             'legacyurl14': ('{% url regressiontests.templates.views.client_action client.id, arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1519             'legacyurl16': ('{% url regressiontests.templates.views.client_action action="update",id="1" %}', {}, '/url_tag/client/1/update/'),
    1520             'legacyurl16a': ("{% url regressiontests.templates.views.client_action action='update',id='1' %}", {}, '/url_tag/client/1/update/'),
    1521             'legacyurl17': ('{% url regressiontests.templates.views.client_action client_id=client.my_id,action=action %}', {'client': {'my_id': 1}, 'action': 'update'}, '/url_tag/client/1/update/'),
    1522 
    1523             'old-url01': ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'),
    1524             'old-url02': ('{% url regressiontests.templates.views.client_action id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1525             'old-url02a': ('{% url regressiontests.templates.views.client_action client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1526             'old-url02b': ("{% url regressiontests.templates.views.client_action id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1527             'old-url02c': ("{% url regressiontests.templates.views.client_action client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1528             'old-url03': ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'),
    1529             'old-url04': ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'),
    1530             'old-url05': (u'{% url метка_оператора v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1531             'old-url06': (u'{% url метка_оператора_2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1532             'old-url07': (u'{% url regressiontests.templates.views.client2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1533             'old-url08': (u'{% url метка_оператора v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1534             'old-url09': (u'{% url метка_оператора_2 tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1535             'old-url10': ('{% url regressiontests.templates.views.client_action id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'),
    1536             'old-url11': ('{% url regressiontests.templates.views.client_action id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'),
    1537             'old-url12': ('{% url regressiontests.templates.views.client_action id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'),
    1538             'old-url13': ('{% url regressiontests.templates.views.client_action id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1539             'old-url14': ('{% url regressiontests.templates.views.client_action client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1540             'old-url15': ('{% url regressiontests.templates.views.client_action 12 "test" %}', {}, '/url_tag/client/12/test/'),
    1541             'old-url16': ('{% url regressiontests.templates.views.client "1,2" %}', {}, '/url_tag/client/1,2/'),
    1542 
    1543             # Failures
    1544             'old-url-fail01': ('{% url %}', {}, template.TemplateSyntaxError),
    1545             'old-url-fail02': ('{% url no_such_view %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1546             'old-url-fail03': ('{% url regressiontests.templates.views.client %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1547             'old-url-fail04': ('{% url view id, %}', {}, template.TemplateSyntaxError),
    1548             'old-url-fail05': ('{% url view id= %}', {}, template.TemplateSyntaxError),
    1549             'old-url-fail06': ('{% url view a.id=id %}', {}, template.TemplateSyntaxError),
    1550             'old-url-fail07': ('{% url view a.id!id %}', {}, template.TemplateSyntaxError),
    1551             'old-url-fail08': ('{% url view id="unterminatedstring %}', {}, template.TemplateSyntaxError),
    1552             'old-url-fail09': ('{% url view id=", %}', {}, template.TemplateSyntaxError),
    1553 
    1554             # {% url ... as var %}
    1555             'old-url-asvar01': ('{% url regressiontests.templates.views.index as url %}', {}, ''),
    1556             'old-url-asvar02': ('{% url regressiontests.templates.views.index as url %}{{ url }}', {}, '/url_tag/'),
    1557             'old-url-asvar03': ('{% url no_such_view as url %}{{ url }}', {}, ''),
    1558 
    1559             # forward compatibility
    1560             # Successes
    1561             'url01': ('{% load url from future %}{% url "regressiontests.templates.views.client" client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'),
    1562             'url02': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1563             'url02a': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1564             'url02b': ("{% load url from future %}{% url 'regressiontests.templates.views.client_action' id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1565             'url02c': ("{% load url from future %}{% url 'regressiontests.templates.views.client_action' client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    1566             'url03': ('{% load url from future %}{% url "regressiontests.templates.views.index" %}', {}, '/url_tag/'),
    1567             'url04': ('{% load url from future %}{% url "named.client" client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'),
    1568             'url05': (u'{% load url from future %}{% url "метка_оператора" v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1569             'url06': (u'{% load url from future %}{% url "метка_оператора_2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1570             'url07': (u'{% load url from future %}{% url "regressiontests.templates.views.client2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1571             'url08': (u'{% load url from future %}{% url "метка_оператора" v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1572             'url09': (u'{% load url from future %}{% url "метка_оператора_2" tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
    1573             'url10': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'),
    1574             'url11': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'),
    1575             'url12': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'),
    1576             'url13': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1577             'url14': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
    1578             'url15': ('{% load url from future %}{% url "regressiontests.templates.views.client_action" 12 "test" %}', {}, '/url_tag/client/12/test/'),
    1579             'url18': ('{% load url from future %}{% url "regressiontests.templates.views.client" "1,2" %}', {}, '/url_tag/client/1,2/'),
    1580 
    1581             'url19': ('{% load url from future %}{% url named_url client.id %}', {'named_url': 'regressiontests.templates.views.client', 'client': {'id': 1}}, '/url_tag/client/1/'),
    1582             'url20': ('{% load url from future %}{% url url_name_in_var client.id %}', {'url_name_in_var': 'named.client', 'client': {'id': 1}}, '/url_tag/named-client/1/'),
     1499            'url01': ('{% url "regressiontests.templates.views.client" client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'),
     1500            'url02': ('{% url "regressiontests.templates.views.client_action" id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
     1501            'url02a': ('{% url "regressiontests.templates.views.client_action" client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
     1502            'url02b': ("{% url 'regressiontests.templates.views.client_action' id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
     1503            'url02c': ("{% url 'regressiontests.templates.views.client_action' client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),
     1504            'url03': ('{% url "regressiontests.templates.views.index" %}', {}, '/url_tag/'),
     1505            'url04': ('{% url "named.client" client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'),
     1506            'url05': (u'{% url "метка_оператора" v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
     1507            'url06': (u'{% url "метка_оператора_2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
     1508            'url07': (u'{% url "regressiontests.templates.views.client2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
     1509            'url08': (u'{% url "метка_оператора" v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
     1510            'url09': (u'{% url "метка_оператора_2" tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),
     1511            'url10': ('{% url "regressiontests.templates.views.client_action" id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'),
     1512            'url11': ('{% url "regressiontests.templates.views.client_action" id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'),
     1513            'url12': ('{% url "regressiontests.templates.views.client_action" id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'),
     1514            'url13': ('{% url "regressiontests.templates.views.client_action" id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
     1515            'url14': ('{% url "regressiontests.templates.views.client_action" client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),
     1516            'url15': ('{% url "regressiontests.templates.views.client_action" 12 "test" %}', {}, '/url_tag/client/12/test/'),
     1517            'url18': ('{% url "regressiontests.templates.views.client" "1,2" %}', {}, '/url_tag/client/1,2/'),
     1518
     1519            'url19': ('{% url named_url client.id %}', {'named_url': 'regressiontests.templates.views.client', 'client': {'id': 1}}, '/url_tag/client/1/'),
     1520            'url20': ('{% url url_name_in_var client.id %}', {'url_name_in_var': 'named.client', 'client': {'id': 1}}, '/url_tag/named-client/1/'),
    15831521
    15841522            # Failures
    1585             'url-fail01': ('{% load url from future %}{% url %}', {}, template.TemplateSyntaxError),
    1586             'url-fail02': ('{% load url from future %}{% url "no_such_view" %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1587             'url-fail03': ('{% load url from future %}{% url "regressiontests.templates.views.client" %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1588             'url-fail04': ('{% load url from future %}{% url "view" id, %}', {}, template.TemplateSyntaxError),
    1589             'url-fail05': ('{% load url from future %}{% url "view" id= %}', {}, template.TemplateSyntaxError),
    1590             'url-fail06': ('{% load url from future %}{% url "view" a.id=id %}', {}, template.TemplateSyntaxError),
    1591             'url-fail07': ('{% load url from future %}{% url "view" a.id!id %}', {}, template.TemplateSyntaxError),
    1592             'url-fail08': ('{% load url from future %}{% url "view" id="unterminatedstring %}', {}, template.TemplateSyntaxError),
    1593             'url-fail09': ('{% load url from future %}{% url "view" id=", %}', {}, template.TemplateSyntaxError),
    1594 
    1595             'url-fail11': ('{% load url from future %}{% url named_url %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1596             'url-fail12': ('{% load url from future %}{% url named_url %}', {'named_url': 'no_such_view'}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1597             'url-fail13': ('{% load url from future %}{% url named_url %}', {'named_url': 'regressiontests.templates.views.client'}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
    1598             'url-fail14': ('{% load url from future %}{% url named_url id, %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    1599             'url-fail15': ('{% load url from future %}{% url named_url id= %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    1600             'url-fail16': ('{% load url from future %}{% url named_url a.id=id %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    1601             'url-fail17': ('{% load url from future %}{% url named_url a.id!id %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    1602             'url-fail18': ('{% load url from future %}{% url named_url id="unterminatedstring %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    1603             'url-fail19': ('{% load url from future %}{% url named_url id=", %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1523            'url-fail01': ('{% url %}', {}, template.TemplateSyntaxError),
     1524            'url-fail02': ('{% url "no_such_view" %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
     1525            'url-fail03': ('{% url "regressiontests.templates.views.client" %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
     1526            'url-fail04': ('{% url "view" id, %}', {}, template.TemplateSyntaxError),
     1527            'url-fail05': ('{% url "view" id= %}', {}, template.TemplateSyntaxError),
     1528            'url-fail06': ('{% url "view" a.id=id %}', {}, template.TemplateSyntaxError),
     1529            'url-fail07': ('{% url "view" a.id!id %}', {}, template.TemplateSyntaxError),
     1530            'url-fail08': ('{% url "view" id="unterminatedstring %}', {}, template.TemplateSyntaxError),
     1531            'url-fail09': ('{% url "view" id=", %}', {}, template.TemplateSyntaxError),
     1532
     1533            'url-fail11': ('{% url named_url %}', {}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
     1534            'url-fail12': ('{% url named_url %}', {'named_url': 'no_such_view'}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
     1535            'url-fail13': ('{% url named_url %}', {'named_url': 'regressiontests.templates.views.client'}, (urlresolvers.NoReverseMatch, urlresolvers.NoReverseMatch)),
     1536            'url-fail14': ('{% url named_url id, %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1537            'url-fail15': ('{% url named_url id= %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1538            'url-fail16': ('{% url named_url a.id=id %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1539            'url-fail17': ('{% url named_url a.id!id %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1540            'url-fail18': ('{% url named_url id="unterminatedstring %}', {'named_url': 'view'}, template.TemplateSyntaxError),
     1541            'url-fail19': ('{% url named_url id=", %}', {'named_url': 'view'}, template.TemplateSyntaxError),
    16041542
    16051543            # {% url ... as var %}
    1606             'url-asvar01': ('{% load url from future %}{% url "regressiontests.templates.views.index" as url %}', {}, ''),
    1607             'url-asvar02': ('{% load url from future %}{% url "regressiontests.templates.views.index" as url %}{{ url }}', {}, '/url_tag/'),
    1608             'url-asvar03': ('{% load url from future %}{% url "no_such_view" as url %}{{ url }}', {}, ''),
     1544            'url-asvar01': ('{% url "regressiontests.templates.views.index" as url %}', {}, ''),
     1545            'url-asvar02': ('{% url "regressiontests.templates.views.index" as url %}{{ url }}', {}, '/url_tag/'),
     1546            'url-asvar03': ('{% url "no_such_view" as url %}{{ url }}', {}, ''),
    16091547
    16101548            ### CACHE TAG ######################################################
    16111549            'cache03': ('{% load cache %}{% cache 2 test %}cache03{% endcache %}', {}, 'cache03'),
  • tests/regressiontests/urlpatterns_reverse/urlconf_inner.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py b/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py
    index 4d3fb74..6d9d234 100644
    a b from django.template import Template, Context  
    33from django.http import HttpResponse
    44
    55def inner_view(request):
    6     content = Template('{% load url from future %}'
    7                        '{% url "outer" as outer_url %}outer:{{ outer_url }},'
     6    content = Template('{% url "outer" as outer_url %}outer:{{ outer_url }},'
    87                       '{% url "inner" as inner_url %}inner:{{ inner_url }}').render(Context())
    98    return HttpResponse(content)
    109
    1110urlpatterns = patterns('',
    1211    url(r'^second_test/$', inner_view, name='inner'),
    13 )
    14  No newline at end of file
     12)
Back to Top