diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000..906d6846b
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,40 @@
+name: Release
+
+on:
+ push:
+ tags:
+ - '*'
+
+jobs:
+ build:
+ if: github.repository == 'jazzband/django-debug-toolbar'
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+
+ - name: Install dependencies
+ run: |
+ python -m pip install -U pip
+ python -m pip install -U setuptools twine wheel
+
+ - name: Build package
+ run: |
+ python setup.py --version
+ python setup.py sdist --format=gztar bdist_wheel
+ twine check dist/*
+
+ - name: Upload packages to Jazzband
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
+ uses: pypa/gh-action-pypi-publish@master
+ with:
+ user: jazzband
+ password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
+ repository_url: https://jazzband.co/projects/django-debug-toolbar/upload
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 000000000..0fd253887
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,222 @@
+name: Test
+
+on: [push, pull_request]
+
+jobs:
+ mysql:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ max-parallel: 5
+ matrix:
+ python-version: ['3.6', '3.7', '3.8', '3.9']
+
+ services:
+ mariadb:
+ image: mariadb:10.3
+ env:
+ MYSQL_ROOT_PASSWORD: mysql
+ MYSQL_DATABASE: mysql
+ options: >-
+ --health-cmd "mysqladmin ping"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 3306:3306
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Get pip cache dir
+ id: pip-cache
+ run: |
+ echo "::set-output name=dir::$(pip cache dir)"
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.pip-cache.outputs.dir }}
+ key:
+ ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
+ restore-keys: |
+ ${{ matrix.python-version }}-v1-
+
+ - name: Install enchant (only for docs)
+ run: |
+ sudo apt-get -qq update
+ sudo apt-get -y install enchant
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install --upgrade tox tox-gh-actions
+
+ - name: Test with tox
+ run: tox
+ env:
+ DB_BACKEND: mysql
+ DB_NAME: mysql
+ DB_USER: root
+ DB_PASSWORD: mysql
+ DB_HOST: "127.0.0.1"
+ DB_PORT: "3306"
+
+ - name: Upload coverage
+ uses: codecov/codecov-action@v1
+ with:
+ name: Python ${{ matrix.python-version }}
+
+ postgres:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ max-parallel: 5
+ matrix:
+ python-version: ['3.6', '3.7', '3.8', '3.9']
+
+ services:
+ postgres:
+ image: 'postgres:9.5'
+ env:
+ POSTGRES_PASSWORD: postgres
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Get pip cache dir
+ id: pip-cache
+ run: |
+ echo "::set-output name=dir::$(pip cache dir)"
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.pip-cache.outputs.dir }}
+ key:
+ ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
+ restore-keys: |
+ ${{ matrix.python-version }}-v1-
+
+ - name: Install enchant (only for docs)
+ run: |
+ sudo apt-get -qq update
+ sudo apt-get -y install enchant
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install --upgrade tox tox-gh-actions
+
+ - name: Test with tox
+ run: tox
+ env:
+ DB_BACKEND: postgresql
+ DB_NAME: postgres
+ DB_USER: postgres
+ DB_PASSWORD: postgres
+ DB_HOST: localhost
+ DB_PORT: 5432
+
+ - name: Upload coverage
+ uses: codecov/codecov-action@v1
+ with:
+ name: Python ${{ matrix.python-version }}
+
+ sqlite:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ max-parallel: 5
+ matrix:
+ python-version: ['3.6', '3.7', '3.8', '3.9']
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Get pip cache dir
+ id: pip-cache
+ run: |
+ echo "::set-output name=dir::$(pip cache dir)"
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.pip-cache.outputs.dir }}
+ key:
+ ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
+ restore-keys: |
+ ${{ matrix.python-version }}-v1-
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install --upgrade tox tox-gh-actions
+
+ - name: Test with tox
+ run: tox
+ env:
+ DB_BACKEND: sqlite3
+ DB_NAME: ":memory:"
+
+ - name: Upload coverage
+ uses: codecov/codecov-action@v1
+ with:
+ name: Python ${{ matrix.python-version }}
+
+ lint:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+
+ - name: Get pip cache dir
+ id: pip-cache
+ run: |
+ echo "::set-output name=dir::$(pip cache dir)"
+
+ - name: Cache
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.pip-cache.outputs.dir }}
+ key:
+ ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
+ restore-keys: |
+ ${{ matrix.python-version }}-v1-
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install --upgrade tox
+
+ - name: Test with tox
+ run: tox -e docs,style,readme
diff --git a/.gitignore b/.gitignore
index 836dfe93d..564e7b8cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,4 @@ htmlcov
node_modules
package-lock.json
geckodriver.log
+coverage.xml
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 76998f37a..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,100 +0,0 @@
-dist: bionic
-language: python
-cache: pip
-matrix:
- fast_finish: true
- include:
- - env: TOXENV=docs
- before_install:
- - sudo apt-get -y install libenchant1c2a
- - env: TOXENV=style
- - env: TOXENV=readme
- - python: 3.5
- env: TOXENV=py35-dj22-sqlite
- - python: 3.6
- env: TOXENV=py36-dj22-sqlite
- - python: 3.7
- env: TOXENV=py37-dj22-sqlite
- - python: 3.8
- env: TOXENV=py38-dj22-sqlite
- - python: 3.6
- env: TOXENV=py36-dj30-sqlite
- - python: 3.7
- env: TOXENV=py37-dj30-sqlite
- - python: 3.8
- env: TOXENV=py38-dj30-sqlite
- - python: 3.6
- env: TOXENV=py36-dj31-sqlite
- - python: 3.7
- env: TOXENV=py37-dj31-sqlite
- - python: 3.8
- env: TOXENV=py38-dj31-sqlite
- - python: 3.6
- env: TOXENV=py36-djmaster-sqlite
- - python: 3.7
- env: TOXENV=py37-djmaster-sqlite
- - python: 3.8
- env: TOXENV=py38-djmaster-sqlite
- - python: 3.8
- env: TOXENV=py38-dj22-postgresql
- addons:
- postgresql: "9.5"
- - python: 3.8
- env: TOXENV=py38-dj30-postgresql
- addons:
- postgresql: "9.5"
- - python: 3.8
- env: TOXENV=py38-dj31-postgresql DJANGO_SELENIUM_TESTS=True
- before_install:
- - wget https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz
- - mkdir geckodriver && tar zxvf geckodriver-v0.27.0-linux64.tar.gz -C geckodriver
- - export PATH=$PATH:$PWD/geckodriver
- addons:
- firefox: latest
- postgresql: "9.5"
- - python: 3.8
- env: TOXENV=py38-dj22-mariadb
- addons:
- mariadb: "10.3"
- script:
- # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160
- - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';"
- - mysql -u root -e "CREATE USER 'travis'@'%';"
- - mysql -u root -e "CREATE DATABASE debug_toolbar;"
- - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';";
- - tox -v
- - python: 3.8
- env: TOXENV=py38-dj30-mariadb
- addons:
- mariadb: "10.3"
- script:
- # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160
- - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';"
- - mysql -u root -e "CREATE USER 'travis'@'%';"
- - mysql -u root -e "CREATE DATABASE debug_toolbar;"
- - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';";
- - tox -v
- - python: 3.8
- env: TOXENV=py38-dj31-mariadb
- addons:
- mariadb: "10.3"
- script:
- # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160
- - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';"
- - mysql -u root -e "CREATE USER 'travis'@'%';"
- - mysql -u root -e "CREATE DATABASE debug_toolbar;"
- - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';";
- - tox -v
- allow_failures:
- - env: TOXENV=py36-djmaster-sqlite
- - env: TOXENV=py37-djmaster-sqlite
- - env: TOXENV=py38-djmaster-sqlite
- - env: TOXENV=py38-djmaster-postgresql
- - env: TOXENV=py38-djmaster-mariadb
-
-install:
- - pip install tox codecov
-script:
- - tox -v
-after_success:
- - codecov
diff --git a/Makefile b/Makefile
index 05ff29203..0ddde5fe7 100644
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,14 @@ PRETTIER_TARGETS = '**/*.(css|js)'
style: package-lock.json
isort .
- black --target-version=py35 .
+ black --target-version=py36 .
flake8
npx eslint --ignore-path .gitignore --fix .
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS)
style_check: package-lock.json
isort -c .
- black --target-version=py35 --check .
+ black --target-version=py36 --check .
flake8
npx eslint --ignore-path .gitignore .
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS)
@@ -36,11 +36,11 @@ test_selenium:
coverage:
python --version
- coverage erase
DJANGO_SETTINGS_MODULE=tests.settings \
python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests}
coverage report
coverage html
+ coverage xml
translatable_strings:
cd debug_toolbar && python -m django makemessages -l en --no-obsolete
diff --git a/README.rst b/README.rst
index 5e02e88b3..ef98a9f70 100644
--- a/README.rst
+++ b/README.rst
@@ -6,14 +6,22 @@ Django Debug Toolbar
:target: https://jazzband.co/
:alt: Jazzband
-.. image:: https://travis-ci.org/jazzband/django-debug-toolbar.svg?branch=master
- :target: https://travis-ci.org/jazzband/django-debug-toolbar
+.. image:: https://github.com/jazzband/django-debug-toolbar/workflows/Test/badge.svg
+ :target: https://github.com/jazzband/django-debug-toolbar/actions
:alt: Build Status
.. image:: https://codecov.io/gh/jazzband/django-debug-toolbar/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jazzband/django-debug-toolbar
:alt: Test coverage status
+.. image:: https://img.shields.io/pypi/pyversions/django-debug-toolbar
+ :target: https://pypi.python.org/pypi/django-debug-toolbar
+ :alt: Supported Python versions
+
+.. image:: https://img.shields.io/pypi/djversions/django-debug-toolbar
+ :target: https://pypi.org/project/django-debug-toolbar
+ :alt: Supported Django versions
+
The Django Debug Toolbar is a configurable set of panels that display various
debug information about the current request/response and when clicked, display
more details about the panel's content.
@@ -26,7 +34,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 3.1. It works on
+The current stable version of the Debug Toolbar is 3.2. It works on
Django ≥ 2.2.
Documentation, including installation and configuration instructions, is
diff --git a/debug_toolbar/panels/cache.py b/debug_toolbar/panels/cache.py
index bd65d7d1c..bfaf7018b 100644
--- a/debug_toolbar/panels/cache.py
+++ b/debug_toolbar/panels/cache.py
@@ -183,7 +183,7 @@ def _store_call_info(
trace=None,
template_info=None,
backend=None,
- **kw
+ **kw,
):
if name == "get":
if return_value is None:
diff --git a/debug_toolbar/panels/history/panel.py b/debug_toolbar/panels/history/panel.py
index 64c985b84..e80d8c93a 100644
--- a/debug_toolbar/panels/history/panel.py
+++ b/debug_toolbar/panels/history/panel.py
@@ -1,8 +1,6 @@
import json
-import sys
from collections import OrderedDict
-from django.conf import settings
from django.http.request import RawPostDataException
from django.template.loader import render_to_string
from django.templatetags.static import static
@@ -51,14 +49,10 @@ def generate_stats(self, request, response):
and request.body
and request.META.get("CONTENT_TYPE") == "application/json"
):
- # Python <= 3.5's json.loads expects a string.
- data = json.loads(
- request.body
- if sys.version_info[:2] > (3, 5)
- else request.body.decode(
- request.encoding or settings.DEFAULT_CHARSET
- )
- )
+ try:
+ data = json.loads(request.body)
+ except ValueError:
+ pass
except RawPostDataException:
# It is not guaranteed that we may read the request data (again).
data = None
diff --git a/debug_toolbar/panels/request.py b/debug_toolbar/panels/request.py
index c75d0077b..95430e5bc 100644
--- a/debug_toolbar/panels/request.py
+++ b/debug_toolbar/panels/request.py
@@ -3,7 +3,7 @@
from django.utils.translation import gettext_lazy as _
from debug_toolbar.panels import Panel
-from debug_toolbar.utils import get_name_from_obj
+from debug_toolbar.utils import get_name_from_obj, get_sorted_request_variable
class RequestPanel(Panel):
@@ -26,13 +26,12 @@ def nav_subtitle(self):
def generate_stats(self, request, response):
self.record_stats(
{
- "get": [(k, request.GET.getlist(k)) for k in sorted(request.GET)],
- "post": [(k, request.POST.getlist(k)) for k in sorted(request.POST)],
- "cookies": [
- (k, request.COOKIES.get(k)) for k in sorted(request.COOKIES)
- ],
+ "get": get_sorted_request_variable(request.GET),
+ "post": get_sorted_request_variable(request.POST),
+ "cookies": get_sorted_request_variable(request.COOKIES),
}
)
+
view_info = {
"view_func": _("
")
diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py
index 7ebedff39..6d97e8d9d 100644
--- a/debug_toolbar/settings.py
+++ b/debug_toolbar/settings.py
@@ -41,6 +41,7 @@
"SHOW_TEMPLATE_CONTEXT": True,
"SKIP_TEMPLATE_PREFIXES": ("django/forms/widgets/", "admin/widgets/"),
"SQL_WARNING_THRESHOLD": 500, # milliseconds
+ "ENABLE_SQL_TOKEN_GROUPING": True,
}
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 28003e224..78b9b7fe2 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -1,21 +1,25 @@
-{% load i18n %}{% load static %}
+{% load i18n static %}
+{% block css %}
+{% endblock %}
+{% block js %}
+{% endblock %}
-