Skip to content

Commit 5bf2ff4

Browse files
committed
Fix double EXPLAIN when calling explain on a queryset
2 parents 0416234 + 0a84caa commit 5bf2ff4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2021
-213
lines changed

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717

1818
- name: Set up Python
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v5
2020
with:
21-
python-version: 3.8
21+
python-version: 3.13
2222

2323
- name: Install dependencies
2424
run: |

.github/workflows/test.yml

+19-42
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,22 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
13-
django-version: ['3.2', '4.0', '4.1', 'main']
14-
postgres-version: ['11', '12']
15-
mariadb-version: ['10.3', '10.4']
12+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
13+
django-version: ['4.2', '5.0', '5.1', 'main']
14+
postgres-version: ['13', '17']
15+
mariadb-version: ['10.6', '10.11', '11.4']
1616
exclude:
17-
# Django >=4.0 drops support for python 3.7 (https://docs.djangoproject.com/en/4.1/faq/install/)
18-
- python-version: '3.7'
19-
django-version: '4.0'
20-
- python-version: '3.7'
21-
django-version: '4.1'
22-
- python-version: '3.7'
23-
django-version: 'main'
24-
25-
# Django <=4.0 doesn't support python 3.11 (https://docs.djangoproject.com/en/4.1/faq/install/)
26-
- python-version: '3.11'
27-
django-version: '3.2'
28-
- python-version: '3.11'
29-
django-version: '4.0'
17+
# Django 5.0 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.0/faq/install/)
18+
- python-version: '3.9'
19+
django-version: '5.0'
3020

31-
# only test Django dev with PostgreSQL 12 and MariaDB 10.4
32-
- django-version: '3.2'
33-
postgres-version: '12'
34-
- django-version: '3.2'
35-
mariadb-version: '10.4'
36-
37-
- django-version: '4.0'
38-
postgres-version: '12'
39-
- django-version: '4.0'
40-
mariadb-version: '10.4'
21+
# Django 5.1 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
22+
- python-version: '3.9'
23+
django-version: '5.1'
4124

42-
- django-version: '4.1'
43-
postgres-version: '12'
44-
- django-version: '4.1'
45-
mariadb-version: '10.4'
46-
47-
- django-version: 'main'
48-
postgres-version: '11'
49-
- django-version: 'main'
50-
mariadb-version: '10.3'
25+
# Django main doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
26+
- python-version: '3.9'
27+
django-version: 'main'
5128

5229
services:
5330
postgres:
@@ -70,28 +47,28 @@ jobs:
7047
MYSQL_ROOT_PASSWORD: mysql
7148
MYSQL_DATABASE: mysql
7249
options: >-
73-
--health-cmd "mysqladmin ping"
50+
--health-cmd "mariadb-admin ping"
7451
--health-interval 10s
7552
--health-timeout 5s
7653
--health-retries 5
7754
ports:
7855
- 3306:3306
7956

8057
steps:
81-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v4
8259

8360
- name: Set up Python ${{ matrix.python-version }}
84-
uses: actions/setup-python@v2
61+
uses: actions/setup-python@v5
8562
with:
8663
python-version: ${{ matrix.python-version }}
8764

8865
- name: Get pip cache dir
8966
id: pip-cache
9067
run: |
91-
echo "::set-output name=dir::$(pip cache dir)"
68+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
9269
9370
- name: Cache
94-
uses: actions/cache@v2
71+
uses: actions/cache@v4
9572
with:
9673
path: ${{ steps.pip-cache.outputs.dir }}
9774
key:
@@ -111,6 +88,6 @@ jobs:
11188
DJANGO: ${{ matrix.django-version }}
11289

11390
- name: Upload coverage
114-
uses: codecov/codecov-action@v1
91+
uses: codecov/codecov-action@v3
11592
with:
11693
name: Python ${{ matrix.python-version }}

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ project/media/
6363
project/tmp/
6464
.vscode/
6565

66-
# Vagrant
67-
.vagrant
68-
6966
# Hardlinks
7067
/django_silky/silk
7168

.pre-commit-config.yaml

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: 'v4.4.0'
3+
rev: 'v5.0.0'
44
hooks:
55
- id: check-merge-conflict
66
- repo: https://github.com/hadialqattan/pycln
7-
rev: v2.1.3
7+
rev: v2.5.0
88
hooks:
99
- id: pycln
1010
args: ['--all']
1111
- repo: https://github.com/asottile/yesqa
12-
rev: v1.4.0
12+
rev: v1.5.0
1313
hooks:
1414
- id: yesqa
1515
- repo: https://github.com/pycqa/isort
16-
rev: '5.12.0'
16+
rev: '5.13.2'
1717
hooks:
1818
- id: isort
1919
args: ['--profile', 'black']
2020
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: 'v4.4.0'
21+
rev: 'v5.0.0'
2222
hooks:
2323
- id: end-of-file-fixer
2424
exclude: >-
@@ -47,21 +47,21 @@ repos:
4747
- id: detect-private-key
4848
exclude: ^examples|(?:tests/ssl)/
4949
- repo: https://github.com/asottile/pyupgrade
50-
rev: 'v3.3.1'
50+
rev: 'v3.19.1'
5151
hooks:
5252
- id: pyupgrade
53-
args: ['--py37-plus', '--keep-mock']
53+
args: ['--keep-mock']
5454
- repo: https://github.com/adamchainz/django-upgrade
55-
rev: '1.13.0'
55+
rev: '1.22.2'
5656
hooks:
5757
- id: django-upgrade
58-
args: [--target-version, '3.2']
59-
- repo: https://github.com/pre-commit/mirrors-autopep8
60-
rev: 'v2.0.1'
58+
args: [--target-version, '4.2']
59+
- repo: https://github.com/hhatto/autopep8
60+
rev: 'v2.3.2'
6161
hooks:
6262
- id: autopep8
6363
- repo: https://github.com/PyCQA/flake8
64-
rev: '6.0.0'
64+
rev: '7.1.1'
6565
hooks:
6666
- id: flake8
6767
exclude: '^docs/'

CHANGELOG.md

+131-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,136 @@
11
# Change Log
22
## Unreleased
33

4+
## [5.3.2](https://github.com/jazzband/django-silk/tree/5.3.2) (2024-12-05)
5+
:release-by: Albert Wang (@albertyw)
6+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.3.1..5.3.2)
7+
8+
**Fixes:**
9+
10+
- Fix missing image from jQuery UI 1.13.2 (#757) @Tatsh
11+
12+
**Maintenance and Cleanup:**
13+
14+
- Adds updated documentation on middleware ordering (#758) @SoyJoseC
15+
- Updated python dependencies (#761, #760) @albertyw
16+
17+
18+
## [5.3.1](https://github.com/jazzband/django-silk/tree/5.3.1) (2024-11-08)
19+
:release-by: Albert Wang (@albertyw)
20+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.3.0..5.3.1)
21+
22+
**Fixes:**
23+
24+
- Fix missing jQuery UI images (#754) @Tatsh
25+
- Fix swallowing exceptions when processing response in silk middleware (#753) @albertyw
26+
27+
28+
## [5.3.0](https://github.com/jazzband/django-silk/tree/5.3.0) (2024-10-25)
29+
:release-by: Albert Wang (@albertyw)
30+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.2.0..5.3.0)
31+
32+
**Note: this release removes support for Django 3.2 and Python 3.8**
33+
34+
**Features/Enhancements:**
35+
36+
- Support python 3.13 (#747)
37+
38+
**Fixes:**
39+
40+
- Upgrade jQuery-UI to 1.13.2 to fix XSS vulnerability (#742)
41+
42+
**Maintenance and Cleanup:**
43+
44+
- Remove Django 3.2 support (#736)
45+
- Drop support for python 3.8 (#749)
46+
- Update python dependencies (#748)
47+
48+
49+
## [5.2.0](https://github.com/jazzband/django-silk/tree/5.2.0) (2024-08-17)
50+
:release-by: Albert Wang (@albertyw)
51+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.1.0..5.2.0)
52+
53+
**Features/Enhancements:**
54+
55+
- Support Django 5.1 (#734, #732) @albertyw
56+
57+
**Fixes:**
58+
59+
- Fix when Session, Authentication or Message middleware are not present (#667) @mgaligniana
60+
- Update 'tables_involved' property to include tables from UPDATE operation (#717) @emregeldegul
61+
- Fix double-escaping of the curl and Python example code (#709) @SpecLad
62+
- Correct units in profiling and requests pages (#725) @ka28kumar
63+
64+
**Maintenance and Cleanup:**
65+
66+
- Update python dependencies (#733) @albertyw
67+
- Refactor SQL query time calculation to use Django aggregation (#720) @beltagymohamed
68+
- Fix test failures on Windows (#707) @SpecLad
69+
- Update workflow actions (#700) @albertyw
70+
- Update test matrix to latest version of django, postgres, and mariadb #701) @albertyw
71+
72+
73+
## [5.1.0](https://github.com/jazzband/django-silk/tree/5.1.0) (2023-12-30)
74+
:release-by: Albert Wang (@albertyw)
75+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.4..5.1.0)
76+
77+
**Upgrading:**
78+
79+
This release includes [Fix deprecation warning for get_storage_class #669](https://github.com/jazzband/django-silk/pull/669)
80+
which deprecates `SILKY_STORAGE_CLASS`. Users should instead use the Django
81+
`STORAGES` configuration. See [README](https://github.com/albertyw/django-silk/blob/master/README.md#profiling)
82+
and [Django documentation](https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES)
83+
for more information.
84+
85+
Also, for python 3.12, the `cProfile` stdlib library cannot be enabled multiple times concurrently.
86+
Silk will therefore skip profiling if another profile is already enabled.
87+
88+
89+
**Features/Enhancements:**
90+
91+
- Allow option to delete profiles (#652) @viralj
92+
93+
**Fixes:**
94+
95+
- Gracefully error out when there are concurrent profilers (#692) @albertyw
96+
- Always disable cProfile as part of cleanup (#699) @albertyw
97+
- Fix when Session, Authentication or Message middlewares are not present (#667) @mgaligniana
98+
99+
**Maintenance and Cleanup:**
100+
101+
- Fix deprecation warning for get_storage_class (#669) @albertyw
102+
- Support Django 4.2 (#685) @albertyw
103+
- Support python 3.12 (#683) @albertyw
104+
- Support Django 5 (#686) @albertyw
105+
- Remove deprecated datetime.timezone.utc (#687) @albertyw
106+
- Derive version from importlib (#697) @robinchow
107+
108+
**Dependencies:**
109+
110+
- Update python dependencies (#693) @albertyw
111+
112+
113+
## [5.0.4](https://github.com/jazzband/django-silk/tree/5.0.4) (2023-09-17)
114+
:release-by: Albert Wang (@albertyw)
115+
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.3..5.0.4)
116+
117+
**Features/Enhancements:**
118+
119+
- Handle case-insensitive sensitive headers (#674) @shtimn
120+
- Add a "pagetitle" block to Silky templates (#661) @vsajip
121+
- Allow to generate more informative profile file name (#638) @k4rl85
122+
123+
**Maintenance and Cleanup:**
124+
125+
- Remove unsupported versions of Django and Python (#668) @albertyw
126+
- Outsource all inline scripts and styles (#635) @sgelis
127+
- Remove support for looking up headers on django &lt;3.2 (#643) @albertyw
128+
129+
**Dependencies:**
130+
131+
- Update python dependencies (#677) @albertyw
132+
133+
4134
## [5.0.3](https://github.com/jazzband/django-silk/tree/5.0.3) (2023-01-12)
5135
:release-by: Albert Wang (@albertyw)
6136
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.2..5.0.3)
@@ -134,7 +264,7 @@
134264
- Add query execution plan to sql_detail (#452)
135265
- Add Python 3.9 compatibility (#404)
136266
- Replace re_path with path
137-
- Fix transaction error for mysql
267+
- Fix transaction error for mysql
138268
- parse query when count joins to match only Keyword
139269
- fix: DB connection to ClearDB when multiple databases
140270
- fix: DataCollector sql_queries model not found on filter(request=self.request)

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Silk is a live profiling and inspection tool for the Django framework. Silk inte
3030

3131
Silk has been tested with:
3232

33-
* Django: 3.2, 4.0, 4.1
34-
* Python: 3.7, 3.8, 3.9, 3.10, 3.11
33+
* Django: 4.2, 5.0, 5.1
34+
* Python: 3.9, 3.10, 3.11, 3.12, 3.13
3535

3636
## Installation
3737

@@ -56,7 +56,7 @@ INSTALLED_APPS = (
5656
)
5757
```
5858

59-
**Note:** The middleware placement is sensitive. If the middleware before `silk.middleware.SilkyMiddleware` returns from `process_request` then `SilkyMiddleware` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from `process_request`. See the [django docs](https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request) for more information on this.
59+
**Note:** The order of middleware is sensitive. If any middleware placed before `silk.middleware.SilkyMiddleware` returns a response without invoking its `get_response`, the `SilkyMiddleware` won’t run. To avoid this, ensure that middleware preceding `SilkyMiddleware` does not bypass or return a response without calling its `get_response`. For further details, check out the [Django documentation](https://docs.djangoproject.com/en/dev/topics/http/middleware/#middleware-order-and-layering).
6060

6161
**Note:** If you are using `django.middleware.gzip.GZipMiddleware`, place that **before** `silk.middleware.SilkyMiddleware`, otherwise you will get an encoding error.
6262

@@ -150,7 +150,7 @@ Before diving into the stack trace to figure out where this request is coming fr
150150

151151
### Profiling
152152

153-
Turn on the SILKY_PYTHON_PROFILER setting to use Python's built-in cProfile profiler. Each request will be separately profiled and the profiler's output will be available on the request's Profiling page in the Silk UI.
153+
Turn on the SILKY_PYTHON_PROFILER setting to use Python's built-in `cProfile` profiler. Each request will be separately profiled and the profiler's output will be available on the request's Profiling page in the Silk UI. Note that as of Python 3.12, `cProfile` cannot run concurrently so [django-silk under Python 3.12 and later will not profile if another profile is running](https://github.com/jazzband/django-silk/pull/692) (even its own profiler in another thread).
154154

155155
```python
156156
SILKY_PYTHON_PROFILER = True
@@ -170,6 +170,16 @@ When enabled, a graph visualisation generated using [gprof2dot](https://github.c
170170
A custom storage class can be used for the saved generated binary `.prof` files:
171171

172172
```python
173+
# For Django >= 4.2 and Django-Silk >= 5.1.0:
174+
# See https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES
175+
STORAGES = {
176+
'SILKY_STORAGE': {
177+
'BACKEND': 'path.to.StorageClass',
178+
},
179+
# ...
180+
}
181+
182+
# For Django < 4.2 or Django-Silk < 5.1.0
173183
SILKY_STORAGE_CLASS = 'path.to.StorageClass'
174184
```
175185

Vagrantfile

-8
This file was deleted.

docs/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ Features
5757
Requirements
5858
------------
5959

60-
* Django: 3.2, 4.0, 4.1
61-
* Python: 3.7, 3.8, 3.9, 3.10
60+
* Django: 4.2, 5.0, 5.1
61+
* Python: 3.9, 3.10, 3.11, 3.12, 3.13

0 commit comments

Comments
 (0)