Skip to content

Upgrade to Django 5.2 and Python 3.12 - #702

Draft
cytadela8-ai wants to merge 1 commit into
warsztatywww:masterfrom
cytadela8-ai:upgrade/django-5.2
Draft

Upgrade to Django 5.2 and Python 3.12#702
cytadela8-ai wants to merge 1 commit into
warsztatywww:masterfrom
cytadela8-ai:upgrade/django-5.2

Conversation

@cytadela8-ai

@cytadela8-ai cytadela8-ai commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Upgrade the application from Django 3.2.18 to Django 5.2.17 and pin the
deployment runtime to Python 3.12.

This update follows Django's upgrade guide, the release notes for Django 4.0
through 5.2, and the corresponding deprecation timeline. It replaces APIs and
settings that were removed during those releases and updates Django-integrated
packages to versions that support Django 5.2 and Python 3.12.

Dependency and runtime changes

  • Pin the runtime image to python:3.12-alpine instead of the floating
    python:alpine image. This makes the intended Python migration explicit and
    prevents a later Alpine image update from changing the Python feature version.
  • Remove Alpine's separate python3-dev package. The official Python image
    already supplies the matching Python 3.12 headers; Alpine's package currently
    installs headers for a different Python feature version.
  • Update Django to 5.2.17 and update Django integrations, test tools, type stubs,
    and psycopg2-binary to Python 3.12-compatible releases.
  • Add crispy-bootstrap4, because Bootstrap 4 templates are no longer bundled
    with django-crispy-forms 2.x.
  • Keep Bleach at 5.0.1 because django-bleach 3.1 requires Bleach 5.x.
  • Use JSON form for the container command and current Docker ENV syntax.

Django compatibility changes

  • Replace the removed STATICFILES_STORAGE setting with the Django 5 STORAGES
    configuration while preserving manifest storage for production static files.
  • Remove the obsolete USE_L10N setting.
  • Replace django.utils.datetime_safe.datetime in a historical migration with
    the standard-library datetime. The migration only constructs ordinary 2020
    dates, so the removed compatibility wrapper is not required.
  • Replace runtime and test uses of pytz.utc with datetime.timezone.utc to use
    Django's zoneinfo-based timezone model.
  • Add Django 5.2-compatible multiple-file form field handling. New Django
    versions require the widget to opt into multiple selection and the field to
    validate each uploaded file separately.
  • Avoid accessing reverse relation managers before FormQuestion has a primary
    key. Django 5.2 now raises a clear error for that invalid state. Existing
    questions retain the same answer and option cleanup behavior.
  • Make parent model admins inherit SortableAdminBase, as required by current
    django-admin-sortable2 when their inlines use SortableInlineAdminMixin.
  • Add the generated wwwforms state migration for Django's current hidden
    reverse relation serialization of related_name='+'.

Authentication changes

  • Render social-login actions as CSRF-protected POST forms. Current
    social-auth-app-django rejects GET requests to begin authentication.
  • Render logout as a CSRF-protected POST form. Django 5.2's logout view no longer
    accepts GET requests.
  • Pass the CSRF token explicitly through isolated template includes so the
    social-login forms render without missing-context warnings.

Test compatibility changes

  • Update existing assertions for Django's current assertFormError() signature
    and validation message.
  • Replace Python's removed assertRaisesRegexp() alias with
    assertRaisesRegex().
  • Update existing timezone assertions to use datetime.timezone.utc.
  • No new tests were added solely for the upgrade.

Verification

  • python -m pip check
  • python manage.py makemigrations --check --dry-run
  • python -W error::DeprecationWarning manage.py test -v 1
    • 293 tests passed
    • deprecation warnings were promoted to errors
  • npm run build-dev
  • production frontend build through docker build
  • Python 3.12 Docker image build completed without Dockerfile warnings
  • git diff --check

Manual Playwright checks covered:

  • homepage
  • current program
  • gallery
  • login page and social-login POST forms
  • Django admin login and dashboard
  • authenticated profile page
  • POST logout and redirect to the login page
  • browser console errors (none observed)

The test runner still reports the existing environment checks for absent OAuth
and email credentials and unavailable nginx media serving. These are expected in
the local test environment and are not Django deprecation warnings.

The existing frontend dependency tree also reports npm audit findings and
Webpack bundle-size/Browserslist warnings. Frontend dependency modernization is
outside this Django and Python runtime upgrade.


This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants