From 198e5e0f73cd637d956c24f2efb9bc5be00bdbf5 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 18 Jan 2019 06:28:07 -0800 Subject: [PATCH] Handle removed staticfiles.templatetags in Django 3.0 Since Django version 1.10, commit: https://github.com/django/django/commit/cf546e11ac76c8dec527e39ff8ce8249a195ab42 The module django.contrib.staticfiles.templatetags.staticfiles does not have the attribute staticfiles_storage. So it doesn't require any attention in StaticFilesPanel. Further, the module django.contrib.staticfiles.templatetags.staticfiles was deprecated in Django 2.1: https://docs.djangoproject.com/en/dev/releases/2.1/#id2 > {% load staticfiles %} and {% load admin_static %} are deprecated in > favor of {% load static %}, which works the same. And will be removed in Django 3.0: https://docs.djangoproject.com/en/dev/releases/3.0/#features-removed-in-3-0 > The staticfiles and admin_static template tag libraries are removed. Importing it causes an ImportError on Django 3.0. Removing the import fixes tests against the Django master branch. --- debug_toolbar/panels/staticfiles.py | 9 ++------- docs/changes.rst | 2 ++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/debug_toolbar/panels/staticfiles.py b/debug_toolbar/panels/staticfiles.py index 10661908b..b99b45791 100644 --- a/debug_toolbar/panels/staticfiles.py +++ b/debug_toolbar/panels/staticfiles.py @@ -5,7 +5,6 @@ from django.conf import settings from django.contrib.staticfiles import finders, storage -from django.contrib.staticfiles.templatetags import staticfiles from django.core.files.storage import get_storage_class from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import LazyObject @@ -97,14 +96,10 @@ def __init__(self, *args, **kwargs): self._paths = {} def enable_instrumentation(self): - storage.staticfiles_storage = ( - staticfiles.staticfiles_storage - ) = DebugConfiguredStorage() + storage.staticfiles_storage = DebugConfiguredStorage() def disable_instrumentation(self): - storage.staticfiles_storage = ( - staticfiles.staticfiles_storage - ) = _original_storage + storage.staticfiles_storage = _original_storage @property def num_used(self): diff --git a/docs/changes.rst b/docs/changes.rst index 8b933eb91..00d520b04 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -4,6 +4,8 @@ Change log UNRELEASED ---------- +* Updated ``StaticFilesPanel`` to be compatible with Django 3.0. + 1.11 (2018-12-03) -----------------