From f5a4349e3d1ce3389741551f833f5586ff3d08ab Mon Sep 17 00:00:00 2001 From: tschilling Date: Sun, 24 Nov 2019 12:51:26 -0600 Subject: [PATCH 01/25] Update the HIDE_IN_STACKTRACES documentation to reflect settings. --- docs/configuration.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 014db2912..c2998c4cc 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -141,8 +141,21 @@ Panel options * ``HIDE_IN_STACKTRACES`` - Default: ``('socketserver', 'threading', 'wsgiref', 'debug_toolbar', - 'django')``. + Default:: + + ( + "socketserver", + "threading", + "wsgiref", + "debug_toolbar", + "django.db", + "django.core.handlers", + "django.core.servers", + "django.utils.decorators", + "django.utils.deprecation", + "django.utils.functional", + ) + Panels: cache, SQL From c7fb77096e661e820cce5652b0183094db275b50 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 09:00:02 -0800 Subject: [PATCH 02/25] Fix tests to pass on Django master branch This behavior changed in upstream commit: https://github.com/django/django/commit/37e6c5b79bd0529a3c85b8c478e4002fd33a2a1d --- tests/panels/test_sql.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/panels/test_sql.py b/tests/panels/test_sql.py index 784bdce12..77a571605 100644 --- a/tests/panels/test_sql.py +++ b/tests/panels/test_sql.py @@ -1,6 +1,7 @@ import datetime import unittest +import django from django.contrib.auth.models import User from django.db import connection from django.db.models import Count @@ -108,10 +109,16 @@ def test_param_conversion(self): # ensure query was logged self.assertEqual(len(self.panel._queries), 3) - self.assertEqual( - tuple([q[1]["params"] for q in self.panel._queries]), - ('["Foo", true, false]', "[10, 1]", '["2017-12-22 16:07:01"]'), - ) + if django.VERSION >= (3, 1): + self.assertEqual( + tuple([q[1]["params"] for q in self.panel._queries]), + ('["Foo"]', "[10, 1]", '["2017-12-22 16:07:01"]'), + ) + else: + self.assertEqual( + tuple([q[1]["params"] for q in self.panel._queries]), + ('["Foo", true, false]', "[10, 1]", '["2017-12-22 16:07:01"]'), + ) def test_binary_param_force_text(self): self.assertEqual(len(self.panel._queries), 0) From 6c68b7c68a4483e4d1b899cb151ad07a32a43bdb Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 11:18:14 -0800 Subject: [PATCH 03/25] Remove duplicate width="100%" in profiling.html Tables already have a width specified in toolbar.css. Further, width attribute on the table element has been deprecated so it is better to use CSS anyway. --- debug_toolbar/templates/debug_toolbar/panels/profiling.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html index 953f8477f..dc55021c0 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html +++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html @@ -1,5 +1,5 @@ {% load i18n %}{% load static %} - +
From 40093bc9e3b6964b544f50d9a8d41b221eced068 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 11:58:07 -0800 Subject: [PATCH 04/25] Remove invalid, unused HTML attribute "depth" "depth" is not an HTML attribute of the element. Further, it is unused. Introduced in 3929bf2066e108695546e2dd8db14579a8710126. --- debug_toolbar/templates/debug_toolbar/panels/profiling.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html index 953f8477f..61d6c32f0 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html +++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html @@ -12,7 +12,7 @@ {% for call in func_list %} - +
{% trans "Call" %}
{% if call.has_subfuncs %} From 87364f7049d16073a7ba8f2ad95e23867b9e622c Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 14:08:00 -0800 Subject: [PATCH 05/25] Remove unnecessary JavaScript function applyStyle() This function iterated over elements and converted data-* attributes to style attributes of the same name. Instead of using JavaScript, simply assign these values as style attributes to begin with. This removes the JavaScript execution time and reduces the number of JavaScript files included with the project as well as downloaded at runtime. --- debug_toolbar/static/debug_toolbar/js/toolbar.js | 7 ------- .../static/debug_toolbar/js/toolbar.profiling.js | 3 --- debug_toolbar/static/debug_toolbar/js/toolbar.sql.js | 5 ----- .../templates/debug_toolbar/panels/profiling.html | 4 +--- .../templates/debug_toolbar/panels/sql.html | 12 +++++------- .../templates/debug_toolbar/panels/sql_explain.html | 2 -- .../templates/debug_toolbar/panels/sql_profile.html | 2 -- .../templates/debug_toolbar/panels/sql_select.html | 2 -- 8 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js delete mode 100644 debug_toolbar/static/debug_toolbar/js/toolbar.sql.js diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js index fff7a2f41..487e9c68d 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js @@ -312,12 +312,6 @@ return value; } }, - applyStyle: function(name) { - var selector = '#djDebug [data-' + name + ']'; - document.querySelectorAll(selector).forEach(function(element) { - element.style[name] = element.getAttribute('data-' + name); - }); - } }; window.djdt = { show_toolbar: djdt.show_toolbar, @@ -325,7 +319,6 @@ init: djdt.init, close: djdt.hide_one_level, cookie: djdt.cookie, - applyStyle: djdt.applyStyle }; document.addEventListener('DOMContentLoaded', djdt.init); })(); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js deleted file mode 100644 index 5823cfbcd..000000000 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js +++ /dev/null @@ -1,3 +0,0 @@ -(function () { - djdt.applyStyle('padding-left'); -})(); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js deleted file mode 100644 index 65093c8ee..000000000 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js +++ /dev/null @@ -1,5 +0,0 @@ -(function () { - djdt.applyStyle('background-color'); - djdt.applyStyle('left'); - djdt.applyStyle('width'); -})(); diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html index 953f8477f..4073cff41 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html +++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html @@ -14,7 +14,7 @@ {% for call in func_list %}
-
+
{% if call.has_subfuncs %} - {% else %} @@ -32,5 +32,3 @@ {% endfor %}
- - diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html index da7e161a2..9dbb6827e 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html @@ -3,7 +3,7 @@
    {% for alias, info in databases %}
  • -   {{ alias }} +   {{ alias }} {{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %} {% if info.similar_count %} {% blocktrans with count=info.similar_count trimmed %} @@ -34,7 +34,7 @@ {% for query in queries %} -   +   + @@ -44,19 +44,19 @@ {% if query.similar_count %} -   +   {% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %} {% endif %} {% if query.duplicate_count %} -   +   {% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %} {% endif %} -
    {{ query.width_ratio }}%
    +
    {{ query.width_ratio }}%
    {{ query.duration|floatformat:"2" }} @@ -113,5 +113,3 @@ {% else %}

    {% trans "No SQL queries were recorded during this request." %}

    {% endif %} - - diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html b/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html index 0c6124c41..2f8d90c1f 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html @@ -33,5 +33,3 @@

    {% trans "SQL explained" %}

    - - diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html b/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html index 8b1f711cf..109b18d2d 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html @@ -40,5 +40,3 @@

    {% trans "SQL profiled" %}

    {% endif %} - - diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_select.html b/debug_toolbar/templates/debug_toolbar/panels/sql_select.html index 6c3765163..b70a15223 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_select.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_select.html @@ -37,5 +37,3 @@

    {% trans "SQL selected" %}

    {% endif %} - - From e0f4f942fa415bac98c55c51657ada1bff658920 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 15:55:07 -0800 Subject: [PATCH 06/25] Use JavaScript dataset API to access data-* attributes Modern browser offer the dataset attribute on elements to access data-* attributes as a property. https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/dataset --- debug_toolbar/static/debug_toolbar/js/toolbar.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js index fff7a2f41..ffd211aae 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js @@ -78,9 +78,9 @@ this.parentElement.classList.add('djdt-active'); var inner = current.querySelector('.djDebugPanelContent .djdt-scroll'), - store_id = djDebug.getAttribute('data-store-id'); + store_id = djDebug.dataset.storeId; if (store_id && inner.children.length === 0) { - var url = djDebug.getAttribute('data-render-panel-url'); + var url = djDebug.dataset.renderPanelUrl; var url_params = new URLSearchParams(); url_params.append('store_id', store_id); url_params.append('panel_id', this.className); @@ -98,7 +98,7 @@ djdt.hide_one_level(); }); $$.on(djDebug, 'click', '.djDebugPanelButton input[type=checkbox]', function() { - djdt.cookie.set(this.getAttribute('data-cookie'), this.checked ? 'on' : 'off', { + djdt.cookie.set(this.dataset.cookie, this.checked ? 'on' : 'off', { path: '/', expires: 10 }); @@ -137,12 +137,12 @@ $$.on(djDebug, 'click', 'a.djToggleSwitch', function(event) { event.preventDefault(); var self = this; - var id = this.getAttribute('data-toggle-id'); - var open_me = this.textContent == this.getAttribute('data-toggle-open'); + var id = this.dataset.toggleId; + var open_me = this.textContent == this.dataset.toggleOpen; if (id === '' || !id) { return; } - var name = this.getAttribute('data-toggle-name'); + var name = this.dataset.toggleName; var container = this.closest('.djDebugPanelContent').querySelector('#' + name + '_' + id); container.querySelectorAll('.djDebugCollapsed').forEach(function(e) { $$.toggle(e, open_me); @@ -154,11 +154,11 @@ if (open_me) { e.classList.add('djSelected'); e.classList.remove('djUnselected'); - self.textContent = self.getAttribute('data-toggle-close'); + self.textContent = self.dataset.toggleClose; } else { e.classList.remove('djSelected'); e.classList.add('djUnselected'); - self.textContent = self.getAttribute('data-toggle-open'); + self.textContent = self.dataset.toggleOpen; } var switch_ = e.querySelector('.djToggleSwitch') if (switch_) switch_.textContent = self.textContent; From af173cbf4ca75c0c1dae459d2da8a1ebf54d0e50 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 17:01:32 -0800 Subject: [PATCH 07/25] Remove unnecessary coerce to int Since Django commit https://github.com/django/django/commit/190d2ff4a7a392adfe0b12552bd71871791d87aa HttpResponse.status_code is always an int. --- debug_toolbar/panels/redirects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/panels/redirects.py b/debug_toolbar/panels/redirects.py index 53f5a301c..8f26f6fc3 100644 --- a/debug_toolbar/panels/redirects.py +++ b/debug_toolbar/panels/redirects.py @@ -15,7 +15,7 @@ class RedirectsPanel(Panel): def process_request(self, request): response = super().process_request(request) - if 300 <= int(response.status_code) < 400: + if 300 <= response.status_code < 400: redirect_to = response.get("Location", None) if redirect_to: status_line = "{} {}".format( From a08cd2cf539cde137d70fdab64a6cccda3b89918 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 8 Dec 2019 15:26:34 -0800 Subject: [PATCH 08/25] Comment out unused Sphinx 'html_static_path' configuration option Fixes Sphinx warning: WARNING: html_static_path entry '_static' does not exist --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 87dff622b..4c93d3065 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,7 +135,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied From 5c4b1b924e44761122b18557119e47de9090a81c Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 08:45:46 -0800 Subject: [PATCH 09/25] Remove end of life Djangos from the test matrix Django 2.0 went end of life April 1, 2019. Django 2.1 went end of life December 2, 2019. These version are no longer receiving bug fixes include for security issues. Their use is not recommended. By removing these version it will reduce total time to run the full test matrix, allowing for faster developing. --- .travis.yml | 12 ------------ docs/changes.rst | 5 +++++ setup.py | 2 -- tox.ini | 8 ++------ 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 438460742..735c47faa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,18 +15,6 @@ matrix: env: TOXENV=py36-dj111 - python: 3.7 env: TOXENV=py37-dj111 - - python: 3.5 - env: TOXENV=py35-dj20 - - python: 3.6 - env: TOXENV=py36-dj20 - - python: 3.7 - env: TOXENV=py37-dj20 - - python: 3.5 - env: TOXENV=py35-dj21 - - python: 3.6 - env: TOXENV=py36-dj21 - - python: 3.7 - env: TOXENV=py37-dj21 - python: 3.5 env: TOXENV=py35-dj22 - python: 3.6 diff --git a/docs/changes.rst b/docs/changes.rst index b8d5b4f49..77b645351 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,6 +1,11 @@ Change log ========== +UNRELEASED +---------- + +* Removed support for end of life Django 2.0 and 2.1. + 2.1 (2019-11-12) ---------------- diff --git a/setup.py b/setup.py index ff045d9c2..c031eacbf 100755 --- a/setup.py +++ b/setup.py @@ -31,8 +31,6 @@ def readall(path): "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", - "Framework :: Django :: 2.0", - "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", "Framework :: Django :: 3.0", "Intended Audience :: Developers", diff --git a/tox.ini b/tox.ini index ffd8bcc61..9b272e2c8 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,6 @@ envlist = style readme py{35,36,37}-dj111 - py{35,36,37}-dj20 - py{35,36,37}-dj21 py{35,36,37}-dj22 py{36,37}-dj30 py{36,37}-djmaster @@ -15,8 +13,6 @@ envlist = [testenv] deps = dj111: Django==1.11.* - dj20: Django==2.0.* - dj21: Django==2.1.* dj22: Django==2.2.* dj30: Django>=3.0b1,<3.1 djmaster: https://github.com/django/django/archive/master.tar.gz @@ -33,7 +29,7 @@ commands = make coverage TEST_ARGS='{posargs:tests}' [testenv:postgresql] deps = - Django==2.1.* + Django==1.11.* coverage Jinja2 html5lib @@ -49,7 +45,7 @@ commands = make coverage TEST_ARGS='{posargs:tests}' [testenv:mariadb] deps = - Django==2.1.* + Django==2.2.* coverage Jinja2 html5lib From 64ceadd450282496749bb77c7f97443e91875615 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Dec 2019 08:35:24 -0800 Subject: [PATCH 10/25] Add Python 3.8 to the test matrix Python 3.8 was released on October 14th, 2019. Also: - Remove 'dist: xenial' from Travis configuration, it is now the default. - Remove Python version from some Travis entires. Travis now defaults to Python 3. - Update Django 3.0 version string. It was released December 2, 2019. --- .travis.yml | 20 +++++++++++--------- docs/changes.rst | 5 +++++ tox.ini | 8 ++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 438460742..e539c8171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,11 @@ -dist: xenial language: python cache: pip matrix: fast_finish: true include: - env: TOXENV=flake8 - - python: 3.7 - env: TOXENV=style - - python: 3.7 - env: TOXENV=readme + - env: TOXENV=style + - env: TOXENV=readme - python: 3.5 env: TOXENV=py35-dj111 - python: 3.6 @@ -33,20 +30,24 @@ matrix: env: TOXENV=py36-dj22 - python: 3.7 env: TOXENV=py37-dj22 + - python: 3.8 + env: TOXENV=py38-dj22 - python: 3.6 env: TOXENV=py36-dj30 - python: 3.7 env: TOXENV=py37-dj30 + - python: 3.8 + env: TOXENV=py38-dj30 - python: 3.6 env: TOXENV=py36-djmaster - python: 3.7 env: TOXENV=py37-djmaster - - python: 3.7 - env: TOXENV=postgresql + - python: 3.8 + env: TOXENV=py38-djmaster + - env: TOXENV=postgresql addons: postgresql: "9.5" - - python: 3.7 - env: TOXENV=mariadb + - env: TOXENV=mariadb addons: mariadb: "10.3" script: @@ -59,6 +60,7 @@ matrix: allow_failures: - env: TOXENV=py36-djmaster - env: TOXENV=py37-djmaster + - env: TOXENV=py38-djmaster install: - pip install tox codecov diff --git a/docs/changes.rst b/docs/changes.rst index b8d5b4f49..913b9842b 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,6 +1,11 @@ Change log ========== +UNRELEASED +---------- + +* Added support for Python 3.8. + 2.1 (2019-11-12) ---------------- diff --git a/tox.ini b/tox.ini index ffd8bcc61..c792d073a 100644 --- a/tox.ini +++ b/tox.ini @@ -6,9 +6,9 @@ envlist = py{35,36,37}-dj111 py{35,36,37}-dj20 py{35,36,37}-dj21 - py{35,36,37}-dj22 - py{36,37}-dj30 - py{36,37}-djmaster + py{35,36,37,38}-dj22 + py{36,37,38}-dj30 + py{36,37,38}-djmaster postgresql mariadb @@ -18,7 +18,7 @@ deps = dj20: Django==2.0.* dj21: Django==2.1.* dj22: Django==2.2.* - dj30: Django>=3.0b1,<3.1 + dj30: Django==3.0.* djmaster: https://github.com/django/django/archive/master.tar.gz coverage Jinja2 From 8595765df3064b922c9d3ca7d38768e6afcf0621 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 8 Dec 2019 16:36:29 -0800 Subject: [PATCH 11/25] Remove unused DOM class djDebugProfileRow Unused since 72d2d436b0764632df714656de788b1328af7f95. --- debug_toolbar/templates/debug_toolbar/panels/profiling.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html index 953f8477f..e0288913a 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html +++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html @@ -12,7 +12,7 @@ {% for call in func_list %} - +
    {% if call.has_subfuncs %} From 12db280a2988d59705551582355421b956092649 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 10 Dec 2019 05:05:12 -0800 Subject: [PATCH 12/25] Drop redundant type attribute from - - - " # noqa + list(User.objects.filter(username="café".encode("utf-8"))) + response = self.panel.process_request(self.request) + self.panel.generate_stats(self.request, response) + self.assertIn("local_var", self.panel.content) + # Verify the escape logic works + self.assertNotIn("