Ticket #18037: 18037-1.diff
File 18037-1.diff, 61.3 KB (added by , 13 years ago) |
---|
-
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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/index.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% if not is_popup %} 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n admin_static admin_modify %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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> 2 2 <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> 3 3 <head> 4 4 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n admin_static admin_modify %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n admin_static admin_list %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n l10n %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n admin_static %} 3 {% load url from future %}4 3 5 4 {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %} 6 5 -
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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 {% load admin_urls %} 5 4 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></div>{% endblock %} 6 5 -
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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 {% 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 %} 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n static %} 3 {% load url from future %}4 3 {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %} 5 4 {% 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 %} 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 %} 2 2 {% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %} 3 3 4 4 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block extrahead %} 6 5 {{ 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block coltype %}colSM{% endblock %} 6 5 -
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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block coltype %}colSM{% endblock %} 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block coltype %}colSM{% endblock %} 6 5 {% 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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block breadcrumbs %} 6 5 <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 1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 {% load url from future %}4 3 5 4 {% block coltype %}colSM{% endblock %} 6 5 {% 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 }}1 unicode: {{ user }} 2 2 id: {{ user.id }} 3 3 username: {{ user.username }} 4 4 url: {% 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): 315 315 return False 316 316 317 317 class SsiNode(Node): 318 def __init__(self, filepath, parsed , legacy_filepath=True):318 def __init__(self, filepath, parsed): 319 319 self.filepath = filepath 320 320 self.parsed = parsed 321 self.legacy_filepath = legacy_filepath322 321 323 322 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) 327 324 328 325 if not include_is_allowed(filepath): 329 326 if settings.DEBUG: … … class TemplateTagNode(Node): 385 382 return self.mapping.get(self.tagtype, '') 386 383 387 384 class URLNode(Node): 388 def __init__(self, view_name, args, kwargs, asvar , legacy_view_name=True):385 def __init__(self, view_name, args, kwargs, asvar): 389 386 self.view_name = view_name 390 self.legacy_view_name = legacy_view_name391 387 self.args = args 392 388 self.kwargs = kwargs 393 389 self.asvar = asvar … … class URLNode(Node): 398 394 kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context)) 399 395 for k, v in self.kwargs.items()]) 400 396 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) 404 398 405 399 # Try to look up the URL twice: once given the view name, and again 406 400 # relative to what we guess is the "main" app. If they both fail, … … def ssi(parser, token): 969 963 of another file -- which must be specified using an absolute path -- 970 964 in the current page:: 971 965 972 {% ssi /home/html/ljworld.com/includes/right_generic.html%}966 {% ssi "/home/html/ljworld.com/includes/right_generic.html" %} 973 967 974 968 If the optional "parsed" parameter is given, the contents of the included 975 969 file are evaluated as template code, with the current context:: 976 970 977 {% ssi /home/html/ljworld.com/includes/right_generic.htmlparsed %}971 {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %} 978 972 """ 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() 985 974 parsed = False 986 975 if len(bits) not in (2, 3): 987 976 raise TemplateSyntaxError("'ssi' tag takes one argument: the path to" … … def ssi(parser, token): 992 981 else: 993 982 raise TemplateSyntaxError("Second (optional) argument to %s tag" 994 983 " 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) 996 986 997 987 @register.tag 998 988 def load(parser, token): … … def url(parser, token): 1201 1191 This is a way to define links that aren't tied to a particular URL 1202 1192 configuration:: 1203 1193 1204 {% url path.to.some_viewarg1 arg2 %}1194 {% url "path.to.some_view" arg1 arg2 %} 1205 1195 1206 1196 or 1207 1197 1208 {% url path.to.some_viewname1=value1 name2=value2 %}1198 {% url "path.to.some_view" name1=value1 name2=value2 %} 1209 1199 1210 The first argument is a path to a view. It can be an absolute python path1200 The first argument is a path to a view. It can be an absolute Python path 1211 1201 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. 1215 1209 1216 1210 For example if you have a view ``app_name.client`` taking client's id and 1217 1211 the corresponding line in a URLconf looks like this:: … … def url(parser, token): 1225 1219 1226 1220 then in a template you can create a link for a certain client like this:: 1227 1221 1228 {% url app_name.clientclient.id %}1222 {% url "app_name.client" client.id %} 1229 1223 1230 1224 The URL will look like ``/clients/client/123/``. 1231 """1232 1225 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 %} 1236 1234 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 """ 1237 1250 bits = token.split_contents() 1238 1251 if len(bits) < 2: 1239 1252 raise TemplateSyntaxError("'%s' takes at least one argument" 1240 1253 " (path to a view)" % bits[0]) 1241 viewname = bits[1]1254 viewname = parser.compile_filter(bits[1]) 1242 1255 args = [] 1243 1256 kwargs = {} 1244 1257 asvar = None … … def url(parser, token): 1247 1260 asvar = bits[-1] 1248 1261 bits = bits[:-2] 1249 1262 1250 # Backwards compatibility: check for the old comma separated format1251 # {% url urlname arg1,arg2 %}1252 # Initial check - that the first space separated bit has a comma in it1253 if bits and ',' in bits[0]:1254 check_old_format = True1255 # In order to *really* be old format, there must be a comma1256 # 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 found1260 # in bit 1 was a false positive (e.g., comma in a string),1261 # or there is a syntax problem with missing commas1262 check_old_format = False1263 break1264 else:1265 # No comma found - must be new format.1266 check_old_format = False1267 1268 if check_old_format:1269 # Confirm that this is old format by trying to parse the first1270 # argument. An exception will be raised if the comma is1271 # 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 vars1282 1263 if len(bits): 1283 1264 for bit in bits: 1284 1265 match = kwarg_re.match(bit) … … def url(parser, token): 1290 1271 else: 1291 1272 args.append(parser.compile_filter(value)) 1292 1273 1293 return URLNode(viewname, args, kwargs, asvar , legacy_view_name=True)1274 return URLNode(viewname, args, kwargs, asvar) 1294 1275 1295 1276 @register.tag 1296 1277 def 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 , TemplateSyntaxError2 from django.template.defaulttags import kwarg_re, SsiNode, URLNode1 from django.template import Library 2 from django.template.defaulttags import url as default_url, ssi as default_ssi 3 3 4 4 register = Library() 5 5 6 6 @register.tag 7 7 def 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) 35 9 36 10 @register.tag 37 11 def 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 2030 2030 .. code-block:: html+django 2031 2031 2032 2032 {% load admin_urls %} 2033 {% load url from future %}2034 2033 <a href="{% url opts|admin_urlname:'add' %}">Add user</a> 2035 2034 <a href="{% url opts|admin_urlname:'delete' user.pk %}">Delete this user</a> 2036 2035 -
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 941 941 another file -- which must be specified using an absolute path -- in the 942 942 current page:: 943 943 944 {% ssi /home/html/ljworld.com/includes/right_generic.html %} 944 {% ssi '/home/html/ljworld.com/includes/right_generic.html' %} 945 946 The first parameter of ``ssi`` can be a quoted literal or any other context 947 variable. 945 948 946 949 If the optional "parsed" parameter is given, the contents of the included 947 950 file are evaluated as template code, within the current context:: 948 951 949 {% ssi /home/html/ljworld.com/includes/right_generic.htmlparsed %}952 {% ssi '/home/html/ljworld.com/includes/right_generic.html' parsed %} 950 953 951 954 Note that if you use ``{% ssi %}``, you'll need to define 952 955 :setting:`ALLOWED_INCLUDE_ROOTS` in your Django settings, as a security … … measure. 954 957 955 958 See also: :ttag:`{% include %}<include>`. 956 959 957 .. admonition:: Forwards compatibility958 959 .. versionchanged:: 1.3960 961 In Django 1.5, the behavior of the :ttag:`ssi` template tag will962 change, with the first argument being made into a context963 variable, rather than being a special case unquoted constant. This964 will allow the :ttag:`ssi` tag to use a context variable as the965 value of the page to be included.966 967 In order to provide a forwards compatibility path, Django 1.3968 provides a future compatibility library -- ``future`` -- that969 implements the new behavior. To use this library, add a970 :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 replaced978 with the behavior provided by the ``future`` tag library.979 Existing templates should be migrated to use the new syntax.980 981 960 .. templatetag:: templatetag 982 961 983 962 templatetag … … given view function and optional parameters. This is a way to output links 1013 992 without violating the DRY principle by having to hard-code URLs in your 1014 993 templates:: 1015 994 1016 {% url path.to.some_viewv1 v2 %}995 {% url 'path.to.some_view' v1 v2 %} 1017 996 1018 997 The 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 999 context variable. Additional arguments are optional and 1020 1000 should be space-separated values that will be used as arguments in the URL. 1021 1001 The example above shows passing positional arguments. Alternatively you may 1022 1002 use keyword syntax:: 1023 1003 1024 {% url path.to.some_viewarg1=v1 arg2=v2 %}1004 {% url 'path.to.some_view' arg1=v1 arg2=v2 %} 1025 1005 1026 1006 Do not mix both positional and keyword syntax in a single call. All arguments 1027 1007 required by the URLconf should be present. … … such as this: 1043 1023 1044 1024 ...then, in a template, you can create a link to this view like this:: 1045 1025 1046 {% url app_views.clientclient.id %}1026 {% url 'app_views.client' client.id %} 1047 1027 1048 1028 The template tag will output the string ``/clients/client/123/``. 1049 1029 … … If you'd like to retrieve a URL without displaying it, you can use a slightly 1059 1039 different call:: 1060 1040 1061 1041 1062 {% url path.to.viewarg arg2 as the_url %}1042 {% url 'path.to.view' arg arg2 as the_url %} 1063 1043 1064 1044 <a href="{{ the_url }}">I'm linking to {{ the_url }}</a> 1065 1045 1066 1046 This ``{% url ... as var %}`` syntax will *not* cause an error if the view is 1067 1047 missing. In practice you'll use this to link to views that are optional:: 1068 1048 1069 {% url path.to.viewas the_url %}1049 {% url 'path.to.view' as the_url %} 1070 1050 {% if the_url %} 1071 1051 <a href="{{ the_url }}">Link to optional stuff</a> 1072 1052 {% endif %} 1073 1053 1074 1054 If you'd like to retrieve a namespaced URL, specify the fully qualified name:: 1075 1055 1076 {% url myapp:view-name%}1056 {% url 'myapp:view-name' %} 1077 1057 1078 1058 This will follow the normal :ref:`namespaced URL resolution strategy 1079 1059 <topics-http-reversing-url-namespaces>`, including using any hints provided 1080 1060 by the context as to the current application. 1081 1061 1082 .. versionchanged:: 1.21083 1084 For backwards compatibility, the ``{% url %}`` tag also supports the1085 use of commas to separate arguments. You shouldn't use this in any new1086 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 equals1093 signs. Did we mention you shouldn't use this syntax in any new1094 projects?1095 1096 .. admonition:: Forwards compatibility1097 1098 .. versionchanged:: 1.31099 1100 In Django 1.5, the behavior of the :ttag:`url` template tag will1101 change, with the first argument being made into a context1102 variable, rather than being a special case unquoted constant. This1103 will allow the :ttag:`url` tag to use a context variable as the1104 value of the URL name to be reversed.1105 1106 In order to provide a forwards compatibility path, Django 1.31107 provides a future compatibility library -- ``future`` -- that1108 implements the new behavior. To use this library, add a1109 :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 for1129 separating arguments to the :ttag:`url` template tag.1130 1131 In Django 1.5, the old behavior will be replaced with the behavior1132 provided by the ``future`` tag library. Existing templates be1133 migrated to use the new syntax.1134 1135 1062 .. templatetag:: widthratio 1136 1063 1137 1064 widthratio -
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 1014 1014 .. code-block:: html+django 1015 1015 1016 1016 {% extends "base.html" %} 1017 {% load url from future %}1018 1017 1019 1018 {% block content %} 1020 1019 … … includes a few other useful built-in views located in 1236 1235 1237 1236 .. code-block:: html+django 1238 1237 1239 {% load url from future %}1240 1238 Someone asked for password reset for email {{ email }}. Follow the link below: 1241 1239 {{ protocol}}://{{ site_name }}{% url 'auth_password_reset_confirm' uidb36=uid token=token %} 1242 1240 -
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: 208 208 209 209 .. code-block:: html+django 210 210 211 {% load tz %} {% load url from future %}211 {% load tz %} 212 212 <form action="{% url 'set_timezone' %}" method="POST"> 213 213 {% csrf_token %} 214 214 <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): 243 243 """ 244 244 Test if the language tag works. 245 245 """ 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 254 246 def test_strings_only(self): 255 247 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 %}""") 258 250 self.assertEqual(t.render(Context({})).strip().split(), 259 251 [u'/vertaald/', u'/traduzidos/']) 260 252 261 253 def test_context(self): 262 254 ctx = Context({'lang1':'nl', 'lang2':'pt-br'}) 263 255 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 %}""") 266 258 self.assertEqual(tpl.render(ctx).strip().split(), 267 259 [u'/vertaald/', u'/traduzidos/']) 268 260 269 261 def test_args(self): 270 262 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 %}""") 273 265 self.assertEqual(tpl.render(Context({})).strip().split(), 274 266 [u'/vertaald/apo/', u'/traduzidos/apo/']) 275 267 276 268 def test_kwargs(self): 277 269 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 %}285 270 {% language 'nl' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %} 286 271 {% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}""") 287 272 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 1 This 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): 1411 1411 ### SSI TAG ######################################################## 1412 1412 1413 1413 # 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'), {}, ''), 1430 1417 1431 1418 # Test passing as a variable 1432 1419 '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'), 1433 1420 'ssi05': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': 'no_file'}, ''), 1434 1421 1435 1422 # 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!'}, ''), 1438 1425 1439 1426 # 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'), 1442 1429 1443 1430 ### TEMPLATETAG TAG ####################################################### 1444 1431 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), … … class Templates(unittest.TestCase): 1509 1496 1510 1497 ### URL TAG ######################################################## 1511 1498 # 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/'), 1583 1521 1584 1522 # 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), 1604 1542 1605 1543 # {% 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 }}', {}, ''), 1609 1547 1610 1548 ### CACHE TAG ###################################################### 1611 1549 '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 3 3 from django.http import HttpResponse 4 4 5 5 def 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 }},' 8 7 '{% url "inner" as inner_url %}inner:{{ inner_url }}').render(Context()) 9 8 return HttpResponse(content) 10 9 11 10 urlpatterns = patterns('', 12 11 url(r'^second_test/$', inner_view, name='inner'), 13 ) 14 No newline at end of file 12 )