diff options
| author | Maxime Turcotte <maxime.turcotte@savoirfairelinux.com> | 2014-03-27 16:24:19 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-03-28 18:55:06 -0400 |
| commit | 5e4e0b6fe97c6c9de8355f8738403691637a0b07 (patch) | |
| tree | f71f9982175d42cc72ab1a646bdfb3a2ddeba64b | |
| parent | 12e9adcd71efa36234b697e47fbf59c8117e29a1 (diff) | |
Fixed #22306 -- Deprecated future versions of cycle and firstof template tags.
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/base.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/change_list_results.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/edit_inline/tabular.html | 2 | ||||
| -rw-r--r-- | django/contrib/admindocs/templates/admin_doc/template_filter_index.html | 2 | ||||
| -rw-r--r-- | django/contrib/admindocs/templates/admin_doc/template_tag_index.html | 2 | ||||
| -rw-r--r-- | django/templatetags/future.py | 14 | ||||
| -rw-r--r-- | django/views/debug.py | 2 | ||||
| -rw-r--r-- | docs/internals/deprecation.txt | 3 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 9 | ||||
| -rw-r--r-- | tests/template_tests/tests.py | 6 |
11 files changed, 33 insertions, 12 deletions
@@ -633,6 +633,7 @@ answer newbie questions, and generally made Django that much better: tt@gurgle.no David Tulig <david.tulig@gmail.com> Justine Tunney <jtunney@lobstertech.com> + Maxime Turcotte <maxocub@riseup.net> Amit Upadhyay <http://www.amitu.com/blog/> Adam Vandenberg Geert Vanderkelen diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index d93128a140..d52554f633 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -1,4 +1,4 @@ -{% load admin_static %}{% load firstof from future %}<!DOCTYPE html> +{% load admin_static %}<!DOCTYPE html> <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> <head> <title>{% block title %}{% endblock %}</title> diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html index 636869895d..e3d4b2549a 100644 --- a/django/contrib/admin/templates/admin/change_list_results.html +++ b/django/contrib/admin/templates/admin/change_list_results.html @@ -1,4 +1,4 @@ -{% load i18n admin_static %}{% load cycle from future %} +{% load i18n admin_static %} {% if result_hidden_fields %} <div class="hiddenfields">{# DIV for HTML validation #} {% for item in result_hidden_fields %}{{ item }}{% endfor %} diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index 9ef6e8f1d5..4548af45dc 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -1,4 +1,4 @@ -{% load i18n admin_static admin_modify %}{% load cycle from future %} +{% load i18n admin_static admin_modify %} <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group"> <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}"> {{ inline_admin_formset.formset.management_form }} 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 04aac39105..44f0c71aae 100644 --- a/django/contrib/admindocs/templates/admin_doc/template_filter_index.html +++ b/django/contrib/admindocs/templates/admin_doc/template_filter_index.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n %}{% load firstof from future %} +{% load i18n %} {% 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 a3c6eaadf4..6196985474 100644 --- a/django/contrib/admindocs/templates/admin_doc/template_tag_index.html +++ b/django/contrib/admindocs/templates/admin_doc/template_tag_index.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n %}{% load firstof from future %} +{% load i18n %} {% block coltype %}colSM{% endblock %} {% block breadcrumbs %} diff --git a/django/templatetags/future.py b/django/templatetags/future.py index 4bd64e8477..46cc51c431 100644 --- a/django/templatetags/future.py +++ b/django/templatetags/future.py @@ -2,7 +2,7 @@ import warnings from django.template import Library from django.template import defaulttags -from django.utils.deprecation import RemovedInDjango19Warning +from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning register = Library() @@ -30,7 +30,7 @@ def cycle(parser, token): """ This is the future version of `cycle` with auto-escaping. The deprecation is now complete and this version is no different - from the non-future version so this can be deprecated (#22306) + from the non-future version so this is deprecated. By default all strings are escaped. @@ -44,6 +44,10 @@ def cycle(parser, token): {% cycle var1 var2|safe var3|safe as somecycle %} """ + warnings.warn( + "Loading the `cycle` tag from the `future` library is deprecated and " + "will be removed in Django 2.0. Use the default `cycle` tag instead.", + RemovedInDjango20Warning) return defaulttags.cycle(parser, token) @@ -52,7 +56,7 @@ def firstof(parser, token): """ This is the future version of `firstof` with auto-escaping. The deprecation is now complete and this version is no different - from the non-future version so this can be deprecated (#22306) + from the non-future version so this is deprecated. This is equivalent to:: @@ -75,4 +79,8 @@ def firstof(parser, token): {% firstof var1 var2|safe var3 "<strong>fallback value</strong>"|safe %} """ + warnings.warn( + "Loading the `firstof` tag from the `future` library is deprecated and " + "will be removed in Django 2.0. Use the default `firstof` tag instead.", + RemovedInDjango20Warning) return defaulttags.firstof(parser, token) diff --git a/django/views/debug.py b/django/views/debug.py index c1acd8191c..2e04905f61 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -984,7 +984,7 @@ Exception Value: {{ exception_value|force_escape }} </html> """ -TECHNICAL_500_TEXT_TEMPLATE = """{% load firstof from future %}{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} +TECHNICAL_500_TEXT_TEMPLATE = """{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} {% firstof exception_value 'No exception message supplied' %} {% if request %} Request Method: {{ request.META.REQUEST_METHOD }} diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 893f44b3cd..e06765742e 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -12,6 +12,9 @@ about each item can often be found in the release notes of two versions prior. 2.0 --- +* ``cycle`` and ``firstof`` template tags will be removed from the ``future`` + template tag library (used during the 1.6/1.7 deprecation period). + .. _deprecation-removed-in-1.9: 1.9 diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 326b58f412..dcf4d59368 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -180,4 +180,11 @@ Miscellaneous Features deprecated in 1.8 ========================== -... +Loading ``cycle`` and ``firstof`` template tags from ``future`` library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Django 1.6 introduced ``{% load cycle from future %}`` and +``{% load firstof from future %}`` syntax for forward compatibility of the +:ttag:`cycle` and :ttag:`firstof` template tags. This syntax is now deprecated +and will be removed in Django 2.0. You can simply remove the +``{% load ... from future %}`` tags. diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index f6cd354046..00ef9f41cf 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -17,7 +17,7 @@ from django.template.loaders import app_directories, filesystem, cached from django.test import RequestFactory, TestCase from django.test.utils import (setup_test_template_loader, restore_template_loaders, override_settings, extend_sys_path) -from django.utils.deprecation import RemovedInDjango19Warning +from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning from django.utils.encoding import python_2_unicode_compatible from django.utils.formats import date_format from django.utils._os import upath @@ -511,7 +511,7 @@ class TemplateRegressionTests(TestCase): def test_ifchanged_render_once(self): """ Test for ticket #19890. The content of ifchanged template tag was rendered twice.""" - template = Template('{% load cycle from future %}{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}') + template = Template('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}') output = template.render(Context({})) self.assertEqual(output, '1st time') @@ -595,6 +595,8 @@ class TemplateTests(TestCase): with warnings.catch_warnings(): # Ignore pending deprecations of loading 'ssi' and 'url' tags from future. warnings.filterwarnings("ignore", category=RemovedInDjango19Warning, module='django.templatetags.future') + # Ignore deprecations of loading 'cycle' and 'firstof' tags from future. + warnings.filterwarnings("ignore", category=RemovedInDjango20Warning, module="django.templatetags.future") test_template = loader.get_template(name) except ShouldNotExecuteException: failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template loading invoked method that shouldn't have been invoked." % (is_cached, invalid_str, template_debug, name)) |
