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 1809bc9182..1878e806f4 100644
--- a/django/contrib/admindocs/templates/admin_doc/template_filter_index.html
+++ b/django/contrib/admindocs/templates/admin_doc/template_filter_index.html
@@ -1,6 +1,5 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
-{% load url from future %}
{% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}
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 18e5d95298..568b118826 100644
--- a/django/contrib/admindocs/templates/admin_doc/template_tag_index.html
+++ b/django/contrib/admindocs/templates/admin_doc/template_tag_index.html
@@ -1,6 +1,5 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
-{% load url from future %}
{% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}
diff --git a/django/contrib/admindocs/templates/admin_doc/view_detail.html b/django/contrib/admindocs/templates/admin_doc/view_detail.html
index 41c812110f..efe5fed9ed 100644
--- a/django/contrib/admindocs/templates/admin_doc/view_detail.html
+++ b/django/contrib/admindocs/templates/admin_doc/view_detail.html
@@ -1,6 +1,5 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
-{% load url from future %}
{% block breadcrumbs %}
diff --git a/django/contrib/admindocs/templates/admin_doc/view_index.html b/django/contrib/admindocs/templates/admin_doc/view_index.html
index e508c84e19..86342c6dd4 100644
--- a/django/contrib/admindocs/templates/admin_doc/view_index.html
+++ b/django/contrib/admindocs/templates/admin_doc/view_index.html
@@ -1,6 +1,5 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
-{% load url from future %}
{% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}
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 5df2a344cc..aa7f784405 100644
--- a/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
@@ -1,4 +1,4 @@
-{% load url from future %}unicode: {{ user }}
+unicode: {{ user }}
id: {{ user.id }}
username: {{ user.username }}
url: {% url 'userpage' user %}
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 954c5d6d19..f0a83d7e9a 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -315,15 +315,12 @@ def include_is_allowed(filepath):
return False
class SsiNode(Node):
- def __init__(self, filepath, parsed, legacy_filepath=True):
+ def __init__(self, filepath, parsed):
self.filepath = filepath
self.parsed = parsed
- self.legacy_filepath = legacy_filepath
def render(self, context):
- filepath = self.filepath
- if not self.legacy_filepath:
- filepath = filepath.resolve(context)
+ filepath = self.filepath.resolve(context)
if not include_is_allowed(filepath):
if settings.DEBUG:
@@ -385,9 +382,8 @@ class TemplateTagNode(Node):
return self.mapping.get(self.tagtype, '')
class URLNode(Node):
- def __init__(self, view_name, args, kwargs, asvar, legacy_view_name=True):
+ def __init__(self, view_name, args, kwargs, asvar):
self.view_name = view_name
- self.legacy_view_name = legacy_view_name
self.args = args
self.kwargs = kwargs
self.asvar = asvar
@@ -398,9 +394,7 @@ class URLNode(Node):
kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context))
for k, v in self.kwargs.items()])
- view_name = self.view_name
- if not self.legacy_view_name:
- view_name = view_name.resolve(context)
+ view_name = self.view_name.resolve(context)
# Try to look up the URL twice: once given the view name, and again
# relative to what we guess is the "main" app. If they both fail,
@@ -969,19 +963,14 @@ def ssi(parser, token):
of another file -- which must be specified using an absolute path --
in the current page::
- {% ssi /home/html/ljworld.com/includes/right_generic.html %}
+ {% ssi "/home/html/ljworld.com/includes/right_generic.html" %}
If the optional "parsed" parameter is given, the contents of the included
file are evaluated as template code, with the current context::
- {% ssi /home/html/ljworld.com/includes/right_generic.html parsed %}
+ {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
"""
-
- import warnings
- 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.',
- category=DeprecationWarning)
-
- bits = token.contents.split()
+ bits = token.split_contents()
parsed = False
if len(bits) not in (2, 3):
raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
@@ -992,7 +981,8 @@ def ssi(parser, token):
else:
raise TemplateSyntaxError("Second (optional) argument to %s tag"
" must be 'parsed'" % bits[0])
- return SsiNode(bits[1], parsed, legacy_filepath=True)
+ filepath = parser.compile_filter(bits[1])
+ return SsiNode(filepath, parsed)
@register.tag
def load(parser, token):
@@ -1201,17 +1191,21 @@ def url(parser, token):
This is a way to define links that aren't tied to a particular URL
configuration::
- {% url path.to.some_view arg1 arg2 %}
+ {% url "path.to.some_view" arg1 arg2 %}
or
- {% url path.to.some_view name1=value1 name2=value2 %}
+ {% url "path.to.some_view" name1=value1 name2=value2 %}
- The first argument is a path to a view. It can be an absolute python path
+ The first argument is a path to a view. It can be an absolute Python path
or just ``app_name.view_name`` without the project name if the view is
- located inside the project. Other arguments are comma-separated values
- that will be filled in place of positional and keyword arguments in the
- URL. All arguments for the URL should be present.
+ located inside the project.
+
+ Other arguments are space-separated values that will be filled in place of
+ positional and keyword arguments in the URL. Don't mix positional and
+ keyword arguments.
+
+ All arguments for the URL should be present.
For example if you have a view ``app_name.client`` taking client's id and
the corresponding line in a URLconf looks like this::
@@ -1225,20 +1219,39 @@ def url(parser, token):
then in a template you can create a link for a certain client like this::
- {% url app_name.client client.id %}
+ {% url "app_name.client" client.id %}
The URL will look like ``/clients/client/123/``.
+
+ The first argument can also be a named URL instead of the Python path to
+ the view callable. For example if the URLconf entry looks like this::
+
+ url('^client/(\d+)/$', name='client-detail-view')
+
+ then in the template you can use::
+
+ {% url "client-detail-view" client.id %}
+
+ There is even another possible value type for the first argument. It can be
+ the name of a template variable that will be evaluated to obtain the view
+ name or the URL name, e.g.::
+
+ {% with view_path="app_name.client" %}
+ {% url view_path client.id %}
+ {% endwith %}
+
+ or,
+
+ {% with url_name="client-detail-view" %}
+ {% url url_name client.id %}
+ {% endwith %}
+
"""
-
- import warnings
- 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.',
- category=DeprecationWarning)
-
bits = token.split_contents()
if len(bits) < 2:
raise TemplateSyntaxError("'%s' takes at least one argument"
" (path to a view)" % bits[0])
- viewname = bits[1]
+ viewname = parser.compile_filter(bits[1])
args = []
kwargs = {}
asvar = None
@@ -1247,38 +1260,6 @@ def url(parser, token):
asvar = bits[-1]
bits = bits[:-2]
- # Backwards compatibility: check for the old comma separated format
- # {% url urlname arg1,arg2 %}
- # Initial check - that the first space separated bit has a comma in it
- if bits and ',' in bits[0]:
- check_old_format = True
- # In order to *really* be old format, there must be a comma
- # in *every* space separated bit, except the last.
- for bit in bits[1:-1]:
- if ',' not in bit:
- # No comma in this bit. Either the comma we found
- # in bit 1 was a false positive (e.g., comma in a string),
- # or there is a syntax problem with missing commas
- check_old_format = False
- break
- else:
- # No comma found - must be new format.
- check_old_format = False
-
- if check_old_format:
- # Confirm that this is old format by trying to parse the first
- # argument. An exception will be raised if the comma is
- # unexpected (i.e. outside of a static string).
- match = kwarg_re.match(bits[0])
- if match:
- value = match.groups()[1]
- try:
- parser.compile_filter(value)
- except TemplateSyntaxError:
- bits = ''.join(bits).split(',')
-
- # Now all the bits are parsed into new format,
- # process them as template vars
if len(bits):
for bit in bits:
match = kwarg_re.match(bit)
@@ -1290,7 +1271,7 @@ def url(parser, token):
else:
args.append(parser.compile_filter(value))
- return URLNode(viewname, args, kwargs, asvar, legacy_view_name=True)
+ return URLNode(viewname, args, kwargs, asvar)
@register.tag
def widthratio(parser, token):
diff --git a/django/templatetags/future.py b/django/templatetags/future.py
index 9fb2d1138f..e6a0127e71 100644
--- a/django/templatetags/future.py
+++ b/django/templatetags/future.py
@@ -1,124 +1,14 @@
-from django.template import Library, TemplateSyntaxError
-from django.template.defaulttags import kwarg_re, SsiNode, URLNode
+from django.template import Library
+from django.template.defaulttags import url as default_url, ssi as default_ssi
register = Library()
@register.tag
def ssi(parser, token):
- """
- Outputs the contents of a given file into the page.
-
- Like a simple "include" tag, the ``ssi`` tag includes the contents
- of another file -- which must be specified using an absolute path --
- in the current page::
-
- {% ssi "/home/html/ljworld.com/includes/right_generic.html" %}
-
- If the optional "parsed" parameter is given, the contents of the included
- file are evaluated as template code, with the current context::
-
- {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
- """
- bits = token.split_contents()
- parsed = False
- if len(bits) not in (2, 3):
- raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
- " the file to be included")
- if len(bits) == 3:
- if bits[2] == 'parsed':
- parsed = True
- else:
- raise TemplateSyntaxError("Second (optional) argument to %s tag"
- " must be 'parsed'" % bits[0])
- filepath = parser.compile_filter(bits[1])
- return SsiNode(filepath, parsed, legacy_filepath=False)
+ # Used for deprecation path during 1.3/1.4, will be removed in 2.0
+ return default_ssi(parser, token)
@register.tag
def url(parser, token):
- """
- Returns an absolute URL matching given view with its parameters.
-
- This is a way to define links that aren't tied to a particular URL
- configuration::
-
- {% url "path.to.some_view" arg1 arg2 %}
-
- or
-
- {% url "path.to.some_view" name1=value1 name2=value2 %}
-
- The first argument is a path to a view. It can be an absolute Python path
- or just ``app_name.view_name`` without the project name if the view is
- located inside the project.
-
- Other arguments are space-separated values that will be filled in place of
- positional and keyword arguments in the URL. Don't mix positional and
- keyword arguments.
-
- All arguments for the URL should be present.
-
- For example if you have a view ``app_name.client`` taking client's id and
- the corresponding line in a URLconf looks like this::
-
- ('^client/(\d+)/$', 'app_name.client')
-
- and this app's URLconf is included into the project's URLconf under some
- path::
-
- ('^clients/', include('project_name.app_name.urls'))
-
- then in a template you can create a link for a certain client like this::
-
- {% url "app_name.client" client.id %}
-
- The URL will look like ``/clients/client/123/``.
-
- The first argument can also be a named URL instead of the Python path to
- the view callable. For example if the URLconf entry looks like this::
-
- url('^client/(\d+)/$', name='client-detail-view')
-
- then in the template you can use::
-
- {% url "client-detail-view" client.id %}
-
- There is even another possible value type for the first argument. It can be
- the name of a template variable that will be evaluated to obtain the view
- name or the URL name, e.g.::
-
- {% with view_path="app_name.client" %}
- {% url view_path client.id %}
- {% endwith %}
-
- or,
-
- {% with url_name="client-detail-view" %}
- {% url url_name client.id %}
- {% endwith %}
-
- """
- bits = token.split_contents()
- if len(bits) < 2:
- raise TemplateSyntaxError("'%s' takes at least one argument"
- " (path to a view)" % bits[0])
- viewname = parser.compile_filter(bits[1])
- args = []
- kwargs = {}
- asvar = None
- bits = bits[2:]
- if len(bits) >= 2 and bits[-2] == 'as':
- asvar = bits[-1]
- bits = bits[:-2]
-
- if len(bits):
- for bit in bits:
- match = kwarg_re.match(bit)
- if not match:
- raise TemplateSyntaxError("Malformed arguments to url tag")
- name, value = match.groups()
- if name:
- kwargs[name] = parser.compile_filter(value)
- else:
- args.append(parser.compile_filter(value))
-
- return URLNode(viewname, args, kwargs, asvar, legacy_view_name=False)
+ # Used for deprecation path during 1.3/1.4, will be removed in 2.0
+ return default_url(parser, token)
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 66791e65db..e54adf0505 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -279,3 +279,6 @@ these changes.
goal of removing all ``django.contrib`` references from the core
Django codebase. The old shortcut will be removed in the 2.0
release.
+
+* ``ssi`` and ``url`` template tags will be removed from the ``future`` template
+ tag library (used during the 1.3/1.4 deprecation period).
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 1163a5b87e..f3e39b9c40 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -2034,7 +2034,6 @@ To allow easier reversing of the admin urls in templates, Django provides an
.. code-block:: html+django
{% load admin_urls %}
- {% load url from future %}
Add user
Delete this user
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 0251dcbca4..5019963f60 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -941,12 +941,15 @@ Like a simple :ttag:`include` tag, ``{% ssi %}`` includes the contents of
another file -- which must be specified using an absolute path -- in the
current page::
- {% ssi /home/html/ljworld.com/includes/right_generic.html %}
+ {% ssi '/home/html/ljworld.com/includes/right_generic.html' %}
+
+The first parameter of ``ssi`` can be a quoted literal or any other context
+variable.
If the optional "parsed" parameter is given, the contents of the included
file are evaluated as template code, within the current context::
- {% ssi /home/html/ljworld.com/includes/right_generic.html parsed %}
+ {% ssi '/home/html/ljworld.com/includes/right_generic.html' parsed %}
Note that if you use ``{% ssi %}``, you'll need to define
:setting:`ALLOWED_INCLUDE_ROOTS` in your Django settings, as a security
@@ -954,30 +957,6 @@ measure.
See also: :ttag:`{% include %}
`.
-.. admonition:: Forwards compatibility
-
- .. versionchanged:: 1.3
-
- In Django 1.5, the behavior of the :ttag:`ssi` template tag will
- change, with the first argument being made into a context
- variable, rather than being a special case unquoted constant. This
- will allow the :ttag:`ssi` tag to use a context variable as the
- value of the page to be included.
-
- In order to provide a forwards compatibility path, Django 1.3
- provides a future compatibility library -- ``future`` -- that
- implements the new behavior. To use this library, add a
- :ttag:`load` call at the top of any template using the :ttag:`ssi`
- tag, and wrap the first argument to the :ttag:`ssi` tag in quotes.
- For example::
-
- {% load ssi from future %}
- {% ssi '/home/html/ljworld.com/includes/right_generic.html' %}
-
- In Django 1.5, the unquoted constant behavior will be replaced
- with the behavior provided by the ``future`` tag library.
- Existing templates should be migrated to use the new syntax.
-
.. templatetag:: templatetag
templatetag
@@ -1013,15 +992,16 @@ given view function and optional parameters. This is a way to output links
without violating the DRY principle by having to hard-code URLs in your
templates::
- {% url path.to.some_view v1 v2 %}
+ {% url 'path.to.some_view' v1 v2 %}
The first argument is a path to a view function in the format
-``package.package.module.function``. Additional arguments are optional and
+``package.package.module.function``. It can be a quoted literal or any other
+context variable. Additional arguments are optional and
should be space-separated values that will be used as arguments in the URL.
The example above shows passing positional arguments. Alternatively you may
use keyword syntax::
- {% url path.to.some_view arg1=v1 arg2=v2 %}
+ {% url 'path.to.some_view' arg1=v1 arg2=v2 %}
Do not mix both positional and keyword syntax in a single call. All arguments
required by the URLconf should be present.
@@ -1043,7 +1023,7 @@ such as this:
...then, in a template, you can create a link to this view like this::
- {% url app_views.client client.id %}
+ {% url 'app_views.client' client.id %}
The template tag will output the string ``/clients/client/123/``.
@@ -1059,79 +1039,26 @@ If you'd like to retrieve a URL without displaying it, you can use a slightly
different call::
- {% url path.to.view arg arg2 as the_url %}
+ {% url 'path.to.view' arg arg2 as the_url %}
I'm linking to {{ the_url }}
This ``{% url ... as var %}`` syntax will *not* cause an error if the view is
missing. In practice you'll use this to link to views that are optional::
- {% url path.to.view as the_url %}
+ {% url 'path.to.view' as the_url %}
{% if the_url %}
Link to optional stuff
{% endif %}
If you'd like to retrieve a namespaced URL, specify the fully qualified name::
- {% url myapp:view-name %}
+ {% url 'myapp:view-name' %}
This will follow the normal :ref:`namespaced URL resolution strategy
`, including using any hints provided
by the context as to the current application.
-.. versionchanged:: 1.2
-
-For backwards compatibility, the ``{% url %}`` tag also supports the
-use of commas to separate arguments. You shouldn't use this in any new
-projects, but for the sake of the people who are still using it,
-here's what it looks like::
-
- {% url path.to.view arg,arg2 %}
- {% url path.to.view arg, arg2 %}
-
-This syntax doesn't support the use of literal commas, or equals
-signs. Did we mention you shouldn't use this syntax in any new
-projects?
-
-.. admonition:: Forwards compatibility
-
- .. versionchanged:: 1.3
-
- In Django 1.5, the behavior of the :ttag:`url` template tag will
- change, with the first argument being made into a context
- variable, rather than being a special case unquoted constant. This
- will allow the :ttag:`url` tag to use a context variable as the
- value of the URL name to be reversed.
-
- In order to provide a forwards compatibility path, Django 1.3
- provides a future compatibility library -- ``future`` -- that
- implements the new behavior. To use this library, add a
- :ttag:`load` call at the top of any template using the :ttag:`url`
- tag, and wrap the first argument to the :ttag:`url` tag in quotes.
- For example::
-
- {% load url from future %}
-
-
- {% url 'app_views.client' %}
-
- {% url 'myapp:view-name' %}
-
- {% with view_path="app_views.client" %}
- {% url view_path client.id %}
- {% endwith %}
-
- {% with url_name="client-detail-view" %}
- {% url url_name client.id %}
- {% endwith %}
-
- The new library also drops support for the comma syntax for
- separating arguments to the :ttag:`url` template tag.
-
- In Django 1.5, the old behavior will be replaced with the behavior
- provided by the ``future`` tag library. Existing templates be
- migrated to use the new syntax.
-
.. templatetag:: widthratio
widthratio
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
index fcd8f4f677..d166fe5bcf 100644
--- a/docs/topics/auth.txt
+++ b/docs/topics/auth.txt
@@ -1020,7 +1020,6 @@ The login_required decorator
.. code-block:: html+django
{% extends "base.html" %}
- {% load url from future %}
{% block content %}
@@ -1242,7 +1241,6 @@ includes a few other useful built-in views located in
.. code-block:: html+django
- {% load url from future %}
Someone asked for password reset for email {{ email }}. Follow the link below:
{{ protocol}}://{{ site_name }}{% url 'auth_password_reset_confirm' uidb36=uid token=token %}
diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt
index d500230110..ec6270c1c4 100644
--- a/docs/topics/i18n/timezones.txt
+++ b/docs/topics/i18n/timezones.txt
@@ -208,7 +208,7 @@ Include a form in ``template.html`` that will ``POST`` to this view:
.. code-block:: html+django
- {% load tz %}{% load url from future %}
+ {% load tz %}