Skip to content

Commit bc36a6d

Browse files
committed
Support Django 4.2–5.2 LTS
- cove/input/models.py: Overrides formfield() to pass assume_scheme='https' on Django 5.0+, to avoid RemovedInDjango60Warning. - cove/management/commands/tests.py: Use datetime.timezone.utc instead of timezone.utc, which was removed in Django 5.0. - cove/settings.py: Remove USE_L10N (default True since Django 4.0, setting removed in 5.0). - setup.py: Change Django range to >=4.2,<5.3. Django 4.2 LTS is supported until April 2026. - ci.yml: Test Django 4.2 and 5.2 on Python 3.10/3.12/3.13. Enable PYTHONWARNINGS=error for all versions.
1 parent ec269a9 commit bc36a6d

5 files changed

Lines changed: 21 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,14 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
python-version: ["3.8", "3.9", "3.10"]
9+
python-version: ["3.10", "3.12", "3.13"]
1010
django-version:
11-
- "Django>=2.2,<2.3"
12-
- "Django>=3.0,<3.1"
13-
- "Django>=3.1,<3.2"
14-
- "Django>=3.2,<3.3"
1511
- "Django>=4.2,<4.3"
12+
- "Django>=5.2,<5.3"
1613
exclude:
17-
# Django 3.1+ supports Python 3.9.
18-
# https://docs.djangoproject.com/en/3.1/releases/3.1.3/
19-
- python-version: "3.9"
20-
django-version: "Django>=2.2,<2.3"
21-
- python-version: "3.9"
22-
django-version: "Django>=3.0,<3.1"
23-
# Django 3.2+ supports Python 3.10.
24-
# https://docs.djangoproject.com/en/3.2/releases/3.2/
25-
- python-version: "3.10"
26-
django-version: "Django>=2.2,<2.3"
27-
- python-version: "3.10"
28-
django-version: "Django>=3.0,<3.1"
29-
- python-version: "3.10"
30-
django-version: "Django>=3.1,<3.2"
14+
# Django 4.2 supports Python 3.8–3.12.
15+
- python-version: "3.13"
16+
django-version: "Django>=4.2,<4.3"
3117
steps:
3218
- uses: actions/checkout@v4
3319
- name: Setup python
@@ -43,14 +29,6 @@ jobs:
4329
PYTHONWARNINGS: error
4430
DJANGO_SETTINGS_MODULE: cove.settings
4531
SECRET_KEY: 7ur)dt+e%1^e6$8_sd-@1h67_5zixe2&39%r2$$8_7v6fr_7ee
46-
if: ${{ matrix.django-version != 'Django>=4.2,<4.3' }}
47-
# Don't set PYTHONWARNING for Django 4.2, as that has some known
48-
# deprecation warnings for 5.0
49-
- run: "py.test -n 2 cove --cov"
50-
env:
51-
DJANGO_SETTINGS_MODULE: cove.settings
52-
SECRET_KEY: 7ur)dt+e%1^e6$8_sd-@1h67_5zixe2&39%r2$$8_7v6fr_7ee
53-
if: ${{ matrix.django-version == 'Django>=4.2,<4.3' }}
5432
- name: Check existing migrations can run and no migrations are missing
5533
env:
5634
DJANGO_SETTINGS_MODULE: cove.settings

cove/input/models.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from werkzeug.http import parse_options_header
1010
import secrets
1111
import string
12+
import django
1213

1314
CONTENT_TYPE_MAP = {
1415
'application/json': 'json',
@@ -26,9 +27,21 @@ def upload_to(instance, filename=''):
2627
return os.path.join(str(instance.pk), random_string, filename)
2728

2829

30+
# This class is only needed while Django<5 is supported.
31+
class URLField(models.URLField):
32+
def formfield(self, **kwargs):
33+
if django.VERSION >= (5, 0):
34+
kwargs.setdefault('assume_scheme', 'https')
35+
return super().formfield(**kwargs)
36+
37+
def deconstruct(self):
38+
name, path, args, kwargs = super().deconstruct()
39+
return name, "django.db.models.URLField", args, kwargs
40+
41+
2942
class SuppliedData(models.Model):
3043
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
31-
source_url = models.URLField(null=True, max_length=2000)
44+
source_url = URLField(null=True, max_length=2000)
3245
original_file = models.FileField(upload_to=upload_to, max_length=256)
3346
current_app = models.CharField(max_length=20)
3447

cove/management/commands/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_expire_files():
1313
recent.original_file.save('test.json', ContentFile('{}'))
1414

1515
old = SuppliedData.objects.create()
16-
old.created = timezone.datetime(2015, 1, 1, tzinfo=timezone.utc)
16+
old.created = timezone.datetime(2015, 1, 1, tzinfo=datetime.timezone.utc)
1717
old.original_file.save('test.json', ContentFile('{}'))
1818

1919
call_command('expire_files')

cove/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@
126126

127127
USE_I18N = True
128128

129-
USE_L10N = True
130-
131129
USE_TZ = True
132130

133131

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
classifiers=["License :: OSI Approved :: BSD License"],
2929
python_requires=">=3.8",
3030
install_requires=[
31-
"Django>=2.2,<4.3",
31+
"Django>=4.2,<5.3",
3232
"django-bootstrap3",
3333
"requests",
3434
"flattentool",

0 commit comments

Comments
 (0)