diff --git a/debug_toolbar/panels/staticfiles.py b/debug_toolbar/panels/staticfiles.py
index 1dc61c1e4..4a0397a02 100644
--- a/debug_toolbar/panels/staticfiles.py
+++ b/debug_toolbar/panels/staticfiles.py
@@ -1,7 +1,6 @@
import contextlib
import uuid
from contextvars import ContextVar
-from dataclasses import dataclass
from os.path import join, normpath
from django.contrib.staticfiles import finders, storage
@@ -10,26 +9,6 @@
from debug_toolbar import panels
-
-@dataclass(eq=True, frozen=True, order=True)
-class StaticFile:
- """
- Representing the different properties of a static file.
- """
-
- path: str
- url: str
-
- def __str__(self):
- return self.path
-
- def real_path(self):
- return finders.find(self.path)
-
- def url(self):
- return self._url
-
-
# This will record and map the StaticFile instances with its associated
# request across threads and async concurrent requests state.
request_id_context_var = ContextVar("djdt_request_id_store")
@@ -47,7 +26,7 @@ def url(self, path):
request_id = request_id_context_var.get()
record_static_file_signal.send(
sender=self,
- staticfile=StaticFile(path=str(path), url=url),
+ staticfile=(str(path), url, finders.find(str(path))),
request_id=request_id,
)
return url
diff --git a/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html b/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html
index aaa7c78ab..4c32e0e41 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html
@@ -25,9 +25,9 @@
{% blocktranslate count apps_count=staticfiles_apps|length %}Static file app
{% blocktranslate count staticfiles_count=staticfiles|length %}Static file{% plural %}Static files{% endblocktranslate %}
{% if staticfiles %}
- {% for staticfile in staticfiles %}
- - {{ staticfile }}
- - {{ staticfile.real_path }}
+ {% for path, url, real_path in staticfiles %}
+ - {{ path }}
+ - {{ real_path }}
{% endfor %}
{% else %}
diff --git a/tests/panels/test_staticfiles.py b/tests/panels/test_staticfiles.py
index 9af7e5bf8..3a665274e 100644
--- a/tests/panels/test_staticfiles.py
+++ b/tests/panels/test_staticfiles.py
@@ -71,8 +71,8 @@ def get_response(request):
{
"paths": [
Path("additional_static/base.css"),
- Path("additional_static/base.css"),
- Path("additional_static/base2.css"),
+ "additional_static/base.css",
+ "additional_static/base2.css",
]
},
)
@@ -82,8 +82,12 @@ def get_response(request):
response = self.panel.process_request(request)
self.panel.generate_stats(self.request, response)
self.assertEqual(self.panel.get_stats()["num_used"], 2)
- self.assertIn('"/static/additional_static/base.css"', self.panel.content, 1)
- self.assertIn('"/static/additional_static/base2.css"', self.panel.content, 1)
+ self.assertIn(
+ 'href="/static/additional_static/base.css"', self.panel.content, 1
+ )
+ self.assertIn(
+ 'href="/static/additional_static/base2.css"', self.panel.content, 1
+ )
def test_storage_state_preservation(self):
"""Ensure the URLMixin doesn't affect storage state"""
@@ -110,7 +114,7 @@ def test_context_variable_lifecycle(self):
url = storage.staticfiles_storage.url("test.css")
self.assertTrue(url.startswith("/static/"))
# Verify file was tracked
- self.assertIn("test.css", [f.path for f in self.panel.used_paths])
+ self.assertIn("test.css", [f[0] for f in self.panel.used_paths])
finally:
request_id_context_var.reset(token)