Skip to content

Commit

Permalink
Remove Django 3.2 support (#736)
Browse files Browse the repository at this point in the history
* Remove tests against Django 3.2

* Upgrade Django-Upgrade pre-commit to target Django 4.2

* Remove Django 3.2 code
  • Loading branch information
albertyw authored Aug 23, 2024
1 parent 729d2bc commit db8507a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Silk is a live profiling and inspection tool for the Django framework. Silk inte

Silk has been tested with:

* Django: 3.2, 4.2, 5.0, 5.1
* Django: 4.2, 5.0, 5.1
* Python: 3.8, 3.9, 3.10, 3.11, 3.12

## Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ Features
Requirements
------------

* Django: 3.2, 4.2, 5.0, 5.1
* Django: 4.2, 5.0, 5.1
* Python: 3.8, 3.9, 3.10
1 change: 0 additions & 1 deletion project/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

ROOT_URLCONF = 'project.urls'

# Django 3.2+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

MIDDLEWARE = [
Expand Down
13 changes: 0 additions & 13 deletions project/tests/test_view_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ def test_order_by(self):


class TestContext(TestCase):
def assertQuerySetEqual(self, *args, **kwargs):
"""
A shim for QuerySetEqual to enable support for multiple versions of Django
TODO: delete this after support for Django 3.2 is dropped
Reference: https://docs.djangoproject.com/en/5.0/topics/testing/tools/#django.test.TransactionTestCase.assertQuerySetEqual
"""
if hasattr(super(), 'assertQuerySetEqual'):
# Django > 3.2
super().assertQuerySetEqual(*args, **kwargs)
else:
# Django < 5.1
super().assertQuerysetEqual(*args, **kwargs)

def test_default(self):
request = Mock(spec_set=['GET', 'session'])
request.session = {}
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
'Framework :: Django :: 5.1',
Expand All @@ -37,7 +36,7 @@
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
install_requires=[
'Django>=3.2',
'Django>=4.2',
'sqlparse',
'autopep8',
'gprof2dot>=2017.09.19',
Expand Down
20 changes: 7 additions & 13 deletions silk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import sqlparse
from django.conf import settings
from django.core.files.storage import storages
from django.core.files.storage.handler import InvalidStorageError
from django.db import models, transaction
from django.db.models import (
BooleanField,
Expand All @@ -27,19 +29,11 @@
from silk.utils.profile_parser import parse_profile

try:
# New in Django 4.2
from django.core.files.storage import storages
from django.core.files.storage.handler import InvalidStorageError
try:
silk_storage = storages['SILKY_STORAGE']
except InvalidStorageError:
from django.utils.module_loading import import_string
storage_class = SilkyConfig().SILKY_STORAGE_CLASS or settings.DEFAULT_FILE_STORAGE
silk_storage = import_string(storage_class)()
except ImportError:
# Deprecated since Django 4.2, Removed in Django 5.1
from django.core.files.storage import get_storage_class
silk_storage = get_storage_class(SilkyConfig().SILKY_STORAGE_CLASS)()
silk_storage = storages['SILKY_STORAGE']
except InvalidStorageError:
from django.utils.module_loading import import_string
storage_class = SilkyConfig().SILKY_STORAGE_CLASS or settings.DEFAULT_FILE_STORAGE
silk_storage = import_string(storage_class)()


# Seperated out so can use in tests w/o models
Expand Down

0 comments on commit db8507a

Please sign in to comment.