Skip to content

Fixes #2158 -- Made static file objects orderable #2161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debug_toolbar/panels/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from debug_toolbar import panels


@dataclass(eq=True, frozen=True)
@dataclass(eq=True, frozen=True, order=True)
class StaticFile:
"""
Representing the different properties of a static file.
Expand Down
14 changes: 10 additions & 4 deletions tests/panels/test_staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,25 @@ def test_insert_content(self):

def test_path(self):
def get_response(request):
# template contains one static file
return render(
request,
"staticfiles/path.html",
{"path": Path("additional_static/base.css")},
{
"paths": [
Path("additional_static/base.css"),
Path("additional_static/base.css"),
Path("additional_static/base2.css"),
]
},
)

self._get_response = get_response
request = RequestFactory().get("/")
response = self.panel.process_request(request)
self.panel.generate_stats(self.request, response)
self.assertEqual(self.panel.get_stats()["num_used"], 1)
self.assertIn('"/static/additional_static/base.css"', self.panel.content)
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)

def test_storage_state_preservation(self):
"""Ensure the URLMixin doesn't affect storage state"""
Expand Down
4 changes: 1 addition & 3 deletions tests/templates/staticfiles/path.html
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{% load static %}
{# A single file used twice #}
{% static path %}{% static path %}
{% load static %}{% for path in paths %}{% static path %}{% endfor %}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy