Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: django-commons/django-debug-toolbar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.4.5
Choose a base ref
...
head repository: django-commons/django-debug-toolbar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.4.6
Choose a head ref
  • 5 commits
  • 10 files changed
  • 4 contributors

Commits on Jul 5, 2024

  1. Close #1509: Revert the infinite recursion fix, Django has changed th…

    …e behavior (#1955)
    matthiask authored Jul 5, 2024
    Copy the full SHA
    dfad5db View commit details

Commits on Jul 6, 2024

  1. Fixed order and grammatical number of panels in documentation (#1956)

    * fixed order and grammatical number of panels in documentation
    * updated changes.rst to reflect change to docs
    bkdekoning authored Jul 6, 2024
    Copy the full SHA
    699c1d9 View commit details

Commits on Jul 9, 2024

  1. [pre-commit.ci] pre-commit autoupdate

    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.1](astral-sh/ruff-pre-commit@v0.5.0...v0.5.1)
    - [github.com/tox-dev/pyproject-fmt: 2.1.3 → 2.1.4](tox-dev/pyproject-fmt@2.1.3...2.1.4)
    pre-commit-ci[bot] authored and tim-schilling committed Jul 9, 2024
    Copy the full SHA
    9bcd6ca View commit details
  2. Alerts panel: Only process HTML responses

    Closes #1959
    matthiask committed Jul 9, 2024
    Copy the full SHA
    982a127 View commit details

Commits on Jul 10, 2024

  1. Version 4.4.6

    tim-schilling committed Jul 10, 2024
    Copy the full SHA
    8f4fa8e View commit details
Showing with 51 additions and 39 deletions.
  1. +2 −2 .pre-commit-config.yaml
  2. +1 −1 README.rst
  3. +1 −1 debug_toolbar/__init__.py
  4. +2 −10 debug_toolbar/middleware.py
  5. +2 −2 debug_toolbar/panels/alerts.py
  6. +13 −0 debug_toolbar/utils.py
  7. +7 −0 docs/changes.rst
  8. +1 −1 docs/conf.py
  9. +21 −21 docs/panels.rst
  10. +1 −1 tests/forms.py
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -44,13 +44,13 @@ repos:
args:
- --fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.5.0'
rev: 'v0.5.1'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.3
rev: 2.1.4
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ Here's a screenshot of the toolbar in action:
In addition to the built-in panels, a number of third-party panels are
contributed by the community.

The current stable version of the Debug Toolbar is 4.4.5. It works on
The current stable version of the Debug Toolbar is 4.4.6. It works on
Django ≥ 4.2.0.

The Debug Toolbar does not currently support `Django's asynchronous views
2 changes: 1 addition & 1 deletion debug_toolbar/__init__.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

# Do not use pkg_resources to find the version but set it here directly!
# see issue #1446
VERSION = "4.4.5"
VERSION = "4.4.6"

# Code that discovers files or modules in INSTALLED_APPS imports this module.
urls = "debug_toolbar.urls", APP_NAME
12 changes: 2 additions & 10 deletions debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
@@ -11,9 +11,7 @@

from debug_toolbar import settings as dt_settings
from debug_toolbar.toolbar import DebugToolbar
from debug_toolbar.utils import clear_stack_trace_caches

_HTML_TYPES = ("text/html", "application/xhtml+xml")
from debug_toolbar.utils import clear_stack_trace_caches, is_processable_html_response


def show_toolbar(request):
@@ -102,13 +100,7 @@ def __call__(self, request):
response.headers[header] = value

# Check for responses where the toolbar can't be inserted.
content_encoding = response.get("Content-Encoding", "")
content_type = response.get("Content-Type", "").split(";")[0]
if (
getattr(response, "streaming", False)
or content_encoding != ""
or content_type not in _HTML_TYPES
):
if not is_processable_html_response(response):
return response

# Insert the toolbar in the response.
4 changes: 2 additions & 2 deletions debug_toolbar/panels/alerts.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
from django.utils.translation import gettext_lazy as _

from debug_toolbar.panels import Panel
from debug_toolbar.utils import is_processable_html_response


class FormParser(HTMLParser):
@@ -138,8 +139,7 @@ def check_invalid_file_form_configuration(self, html_content):
return self.alerts

def generate_stats(self, request, response):
# check if streaming response
if getattr(response, "streaming", True):
if not is_processable_html_response(response):
return

html_content = response.content.decode(response.charset)
13 changes: 13 additions & 0 deletions debug_toolbar/utils.py
Original file line number Diff line number Diff line change
@@ -353,3 +353,16 @@ def get_stack_trace(*, skip=0):
def clear_stack_trace_caches():
if hasattr(_local_data, "stack_trace_recorder"):
del _local_data.stack_trace_recorder


_HTML_TYPES = ("text/html", "application/xhtml+xml")


def is_processable_html_response(response):
content_encoding = response.get("Content-Encoding", "")
content_type = response.get("Content-Type", "").split(";")[0]
return (
not getattr(response, "streaming", False)
and content_encoding == ""
and content_type in _HTML_TYPES
)
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
@@ -4,6 +4,13 @@ Change log
Pending
-------

4.4.6 (2024-07-10)
------------------

* Changed ordering (and grammatical number) of panels and their titles in
documentation to match actual panel ordering and titles.
* Skipped processing the alerts panel when response isn't a HTML response.

4.4.5 (2024-07-05)
------------------

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
copyright = copyright.format(datetime.date.today().year)

# The full version, including alpha/beta/rc tags
release = "4.4.5"
release = "4.4.6"


# -- General configuration ---------------------------------------------------
42 changes: 21 additions & 21 deletions docs/panels.rst
Original file line number Diff line number Diff line change
@@ -9,17 +9,6 @@ Default built-in panels

The following panels are enabled by default.

Alerts
~~~~~~~

.. class:: debug_toolbar.panels.alerts.AlertsPanel

This panel shows alerts for a set of pre-defined cases:

- Alerts when the response has a form without the
``enctype="multipart/form-data"`` attribute and the form contains
a file input.

History
~~~~~~~

@@ -33,8 +22,8 @@ snapshot of the toolbar to view that request's stats.
``True`` or if the server runs with multiple processes, the History Panel
will be disabled.

Version
~~~~~~~
Versions
~~~~~~~~

.. class:: debug_toolbar.panels.versions.VersionsPanel

@@ -80,19 +69,30 @@ SQL

SQL queries including time to execute and links to EXPLAIN each query.

Template
~~~~~~~~
Static files
~~~~~~~~~~~~

.. class:: debug_toolbar.panels.staticfiles.StaticFilesPanel

Used static files and their locations (via the ``staticfiles`` finders).

Templates
~~~~~~~~~

.. class:: debug_toolbar.panels.templates.TemplatesPanel

Templates and context used, and their template paths.

Static files
~~~~~~~~~~~~
Alerts
~~~~~~~

.. class:: debug_toolbar.panels.staticfiles.StaticFilesPanel
.. class:: debug_toolbar.panels.alerts.AlertsPanel

Used static files and their locations (via the ``staticfiles`` finders).
This panel shows alerts for a set of pre-defined cases:

- Alerts when the response has a form without the
``enctype="multipart/form-data"`` attribute and the form contains
a file input.

Cache
~~~~~
@@ -101,8 +101,8 @@ Cache

Cache queries. Is incompatible with Django's per-site caching.

Signal
~~~~~~
Signals
~~~~~~~

.. class:: debug_toolbar.panels.signals.SignalsPanel

2 changes: 1 addition & 1 deletion tests/forms.py
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@ class TemplateReprForm(forms.Form):
user = forms.ModelChoiceField(queryset=User.objects.all())

def __repr__(self):
return repr(self)
return str(self)