summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-12-27 20:41:54 -0500
committerTim Graham <timograham@gmail.com>2019-01-17 10:52:19 -0500
commit92d4d0859a63347de6e2a7bc3ddd49979cc192c5 (patch)
treee8257beec76b3e488beca0b1e3f783fc1234aa45
parent958a7b4ca69434d0145fd569cf007e21841bb36c (diff)
Refs #21221 -- Removed staticfiles and admin_static template tag libraries.
Per deprecation timeline.
-rw-r--r--django/contrib/admin/templatetags/admin_static.py16
-rw-r--r--django/contrib/staticfiles/templatetags/__init__.py0
-rw-r--r--django/contrib/staticfiles/templatetags/staticfiles.py28
-rw-r--r--docs/releases/3.0.txt4
-rw-r--r--tests/admin_views/test_static_deprecation.py24
-rw-r--r--tests/staticfiles_tests/test_templatetag_deprecation.py36
6 files changed, 4 insertions, 104 deletions
diff --git a/django/contrib/admin/templatetags/admin_static.py b/django/contrib/admin/templatetags/admin_static.py
deleted file mode 100644
index 6b1738dd87..0000000000
--- a/django/contrib/admin/templatetags/admin_static.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import warnings
-
-from django.template import Library
-from django.templatetags.static import static as _static
-from django.utils.deprecation import RemovedInDjango30Warning
-
-register = Library()
-
-
-@register.simple_tag
-def static(path):
- warnings.warn(
- '{% load admin_static %} is deprecated in favor of {% load static %}.',
- RemovedInDjango30Warning,
- )
- return _static(path)
diff --git a/django/contrib/staticfiles/templatetags/__init__.py b/django/contrib/staticfiles/templatetags/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/django/contrib/staticfiles/templatetags/__init__.py
+++ /dev/null
diff --git a/django/contrib/staticfiles/templatetags/staticfiles.py b/django/contrib/staticfiles/templatetags/staticfiles.py
deleted file mode 100644
index 9fa3926412..0000000000
--- a/django/contrib/staticfiles/templatetags/staticfiles.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import warnings
-
-from django import template
-from django.templatetags.static import (
- do_static as _do_static, static as _static,
-)
-from django.utils.deprecation import RemovedInDjango30Warning
-
-register = template.Library()
-
-
-def static(path):
- warnings.warn(
- 'django.contrib.staticfiles.templatetags.static() is deprecated in '
- 'favor of django.templatetags.static.static().',
- RemovedInDjango30Warning,
- stacklevel=2,
- )
- return _static(path)
-
-
-@register.tag('static')
-def do_static(parser, token):
- warnings.warn(
- '{% load staticfiles %} is deprecated in favor of {% load static %}.',
- RemovedInDjango30Warning,
- )
- return _do_static(parser, token)
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index 99db02a0aa..a76f174208 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -256,3 +256,7 @@ to remove usage of these features.
* The ``ForceRHR`` GIS function is removed.
* ``django.utils.http.cookie_date()`` is removed.
+
+* The ``staticfiles`` and ``admin_static`` template tag libraries are removed.
+
+* ``django.contrib.staticfiles.templatetags.staticfiles.static()`` is removed.
diff --git a/tests/admin_views/test_static_deprecation.py b/tests/admin_views/test_static_deprecation.py
deleted file mode 100644
index 166e27ef37..0000000000
--- a/tests/admin_views/test_static_deprecation.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from django.contrib.admin.templatetags.admin_static import static
-from django.contrib.staticfiles.storage import staticfiles_storage
-from django.test import SimpleTestCase
-from django.utils.deprecation import RemovedInDjango30Warning
-
-
-class AdminStaticDeprecationTests(SimpleTestCase):
- def test(self):
- """
- admin_static.static points to the collectstatic version
- (as django.contrib.collectstatic is in INSTALLED_APPS).
- """
- msg = (
- '{% load admin_static %} is deprecated in favor of '
- '{% load static %}.'
- )
- old_url = staticfiles_storage.base_url
- staticfiles_storage.base_url = '/test/'
- try:
- with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
- url = static('path')
- self.assertEqual(url, '/test/path')
- finally:
- staticfiles_storage.base_url = old_url
diff --git a/tests/staticfiles_tests/test_templatetag_deprecation.py b/tests/staticfiles_tests/test_templatetag_deprecation.py
deleted file mode 100644
index 898ee68093..0000000000
--- a/tests/staticfiles_tests/test_templatetag_deprecation.py
+++ /dev/null
@@ -1,36 +0,0 @@
-from urllib.parse import urljoin
-
-from django.contrib.staticfiles import storage
-from django.contrib.staticfiles.templatetags.staticfiles import static
-from django.template import Context, Template
-from django.test import SimpleTestCase, override_settings
-from django.utils.deprecation import RemovedInDjango30Warning
-
-
-class StaticTestStorage(storage.StaticFilesStorage):
- def url(self, name):
- return urljoin('https://example.com/assets/', name)
-
-
-@override_settings(
- STATIC_URL='http://media.example.com/static/',
- INSTALLED_APPS=('django.contrib.staticfiles',),
- STATICFILES_STORAGE='staticfiles_tests.test_forms.StaticTestStorage',
-)
-class StaticDeprecationTests(SimpleTestCase):
- def test_templatetag_deprecated(self):
- msg = '{% load staticfiles %} is deprecated in favor of {% load static %}.'
- template = "{% load staticfiles %}{% static 'main.js' %}"
- with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
- template = Template(template)
- rendered = template.render(Context())
- self.assertEqual(rendered, 'https://example.com/assets/main.js')
-
- def test_static_deprecated(self):
- msg = (
- 'django.contrib.staticfiles.templatetags.static() is deprecated in '
- 'favor of django.templatetags.static.static().'
- )
- with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
- url = static('main.js')
- self.assertEqual(url, 'https://example.com/assets/main.js')