Skip to contentSkip to conversation

Upgrade to Django 5.2

PATCH New Tim Orling 1 participant 4 messages Oct 18

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

cover Upgrade to Django 5.2

Django 4.2 LTS support ends in April 2026, so we should be proactive and upgrade to 5.2 before then.

Tim Orling (3):
Upgrade to Django 5.2.
Update base images to Python 3.12 and MySQL 8.4.
Add a GitHub Actions workflow to scan dependencies with Safety.

 .github/workflows/safety.yml | 39 ++++++++++++++++++++++++++++++++++++
 .safety-project.ini          |  5 +++++
 Dockerfile                   |  6 +++---
 docker-compose.yaml          |  2 +-
 docker/run-tests.sh          |  2 +-
 project/settings.py          |  6 ------
 project/settings.py.docker   |  6 ------
 requirements.txt             | 10 ++++-----
 8 files changed, 54 insertions(+), 22 deletions(-)
 create mode 100644 .github/workflows/safety.yml
 create mode 100644 .safety-project.ini

base-commit: 752b7188d04c2fd0e2f32f0cd2dd437c43058d82
prerequisite-patch-id: 9c9d012e1163dd1d335531d0451657823f17eb64
prerequisite-patch-id: ddb4df3e54736ed25846f91d4918299e601f4071
prerequisite-patch-id: ab69f4aa494291611cbe0e916f18b07f4aeebe57
prerequisite-patch-id: ac2b802ea065536df3854c48e265f5508d201cff
prerequisite-patch-id: 81a7de0e9568848efc8c66d397abb5f56218db95

Signature · 1 line
2.56.0
author
#1 lore raw

PATCH 1/3 Upgrade to Django 5.2.

Django 4.2.30 has 7 known vulnerabilities, fixed in 5.2.18. Pin the other requirements to the installed versions. Drop USE_L10N, removed in 5.0, and AUTH_PROFILE_MODULE, unused since 1.7. No migrations needed.

[YOCTO #16458]

AI-Generated: Claude Opus 5.5

---
 project/settings.py        |  6 ------
 project/settings.py.docker |  6 ------
 requirements.txt           | 10 +++++-----
 3 files changed, 5 insertions(+), 17 deletions(-)
project/settings.py +0 -6
index 1ec6891..bc63c49 100644
@@ -87,10 +87,6 @@ SITE_ID = 1
 # to load the internationalization machinery.
 USE_I18N = True
 
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale.
-USE_L10N = True
-
 # If you set this to False, Django will not use timezone-aware datetimes.
 USE_TZ = True
 
@@ -218,8 +214,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
   'Post.views.common_context',
 )
 
-AUTH_PROFILE_MODULE = 'registration.RegistrationProfile'
-
 BUGZILLA_URL = 'https://bugzilla.yoctoproject.org'
 
 ACCOUNT_ACTIVATION_DAYS = 2
project/settings.py.docker +0 -6
index 9f98715..680b485 100644
@@ -81,10 +81,6 @@ SITE_ID = 1
 # to load the internationalization machinery.
 USE_I18N = True
 
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale.
-USE_L10N = True
-
 # If you set this to False, Django will not use timezone-aware datetimes.
 USE_TZ = True
 
@@ -212,8 +208,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
   'Post.views.common_context',
 )
 
-AUTH_PROFILE_MODULE = 'registration.RegistrationProfile'
-
 BUGZILLA_URL = 'https://bugzilla.yoctoproject.org'
 
 ACCOUNT_ACTIVATION_DAYS = 2
requirements.txt +5 -5
index 920d9d0..f5022da 100644
@@ -1,5 +1,5 @@
-Django<4.3
-python-Levenshtein
-bleach
-mysqlclient
-django-registration
+Django>=5.2.18,<5.3
+python-Levenshtein==0.27.4
+bleach==6.4.0
+mysqlclient==2.3.0
+django-registration==5.2.1
Signature · 1 line
2.56.0
author
#2 lore raw

PATCH 2/3 Update base images to Python 3.12 and MySQL 8.4.

In reply to Tim Orling

Python 3.10 is end of life in October 2026, MySQL 8.0 was in April 2026. Test against the same MySQL as compose. Use ENV key=value, which docker build no longer warns about.

AI-Generated: Claude Opus 5.5

---
 Dockerfile          | 6 +++---
 docker-compose.yaml | 2 +-
 docker/run-tests.sh | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
Dockerfile +3 -3
index 080befc..94d55a6 100644
@@ -1,9 +1,9 @@
 # Use an official Python runtime as a parent image
-FROM python:3.10
+FROM python:3.12
 
 # Set environment variables
-ENV PYTHONDONTWRITEBYTECODE 1
-ENV PYTHONUNBUFFERED 1
+ENV PYTHONDONTWRITEBYTECODE=1
+ENV PYTHONUNBUFFERED=1
 
 # Set the working directory
 WORKDIR /app
docker-compose.yaml +1 -1
index 5ef4913..0291ff5 100644
@@ -1,7 +1,7 @@
 version: '3'
 services:
   db:
-    image: mysql:8.0.36
+    image: mysql:8.4
     container_name: error_report_web_db
     restart: always
     volumes:
docker/run-tests.sh +1 -1
index 54aaa8b..2eafd98 100755
@@ -17,7 +17,7 @@ trap 'docker rm -f $DB >/dev/null; docker network rm $NET >/dev/null' EXIT
 # Root so Django can create the test database; testingpw isn't a secret.
 docker run -d --name $DB --network $NET --network-alias db \
     -e MYSQL_ROOT_PASSWORD=testingpw -e MYSQL_DATABASE=errorreport \
-    mysql:8.0.36 >/dev/null
+    mysql:8.4 >/dev/null
 until docker exec $DB mysql -h127.0.0.1 -uroot -ptestingpw -e 'SELECT 1' >/dev/null 2>&1; do
     if [ "$(docker inspect -f '{{.State.Running}}' $DB)" != true ]; then
         docker logs $DB | tail -5; exit 1
Signature · 1 line
2.56.0
author
#3 lore raw

PATCH 3/3 Add a GitHub Actions workflow to scan dependencies with Safety.

In reply to Tim Orling

Scan the packages installed in the image, weekly and on push, as layerindex-web does. Skipped without SAFETY_API_KEY.

AI-Generated: Claude Opus 5.5

---
 .github/workflows/safety.yml | 39 ++++++++++++++++++++++++++++++++++++
 .safety-project.ini          |  5 +++++
 2 files changed, 44 insertions(+)
 create mode 100644 .github/workflows/safety.yml
 create mode 100644 .safety-project.ini
.github/workflows/safety.yml new file +39 -0
new file mode 100644
index 0000000..768229d
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: MIT
+
+name: Safety
+
+on:
+  push:
+    branches: [master,master-next]
+  schedule:
+    - cron: '0 6 * * 1'
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  scan:
+    runs-on: ubuntu-latest
+    timeout-minutes: 15
+    env:
+      SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }}
+    # Skipped where the secret isn't set, e.g. forks.
+    steps:
+      - uses: actions/checkout@v5
+
+      - name: Build image
+        if: env.SAFETY_API_KEY != ''
+        run: docker build -t error-report-web-test .
+
+      # Scan what's installed, not requirements.txt ranges.
+      - name: Safety scan
+        if: env.SAFETY_API_KEY != ''
+        run: |
+          mkdir safety-scan
+          cp .safety-project.ini safety-scan/
+          docker run --rm error-report-web-test pip3 freeze > safety-scan/requirements.txt
+          # typer pinned: newer releases break safety 3.7.0 ("no active click context")
+          python3 -m venv /tmp/safety
+          /tmp/safety/bin/pip install -q safety==3.7.0 typer==0.23.0
+          /tmp/safety/bin/safety scan --target safety-scan --detailed-output
.safety-project.ini new file +5 -0
new file mode 100644
index 0000000..29b7a3b
@@ -0,0 +1,5 @@
+[project]
+id = error-report-web
+url = /codebases/error-report-web/findings
+name = error-report-web
+
Signature · 1 line
2.56.0