Repository navigation
Support for Django 5.2 / 6.0 - #194
Open
stereodamage wants to merge 3 commits into
Open
stereodamage wants to merge 3 commits into
stereodamage wants to merge 3 commits into
Conversation
Support the async session API introduced in Django 5.1 by mirroring the sync `SessionStore` overrides with async counterparts (`aset`, `acreate`, `_aget_session_from_db`, `acreate_model_instance`). Without these, sessions saved from async code (e.g. via `auth.alogin()`) silently lost the user, user_agent and ip values, since Django's async DBStore methods do not delegate to their sync equivalents. Note that `alogin()` writes the session key through `aset()`, bypassing `__setitem__`. Adapt the GeoIP test fixtures to Django 5.1+, where GeoIP2 uses a single database: country lookups now hit the city database when GEOIP_CITY is configured, so the city fixture needs a country-only record for 8.8.8.8. Remains compatible with the country-database lookup path of older Django. Drop support for Django 3.2 and 4.2 (EOL April 2024 and April 2026) and Python 3.7-3.9, raising the floor to Django 5.2 LTS and Python 3.10. Remove code the new floor makes dead: the pkg_resources version fallback, the `django.contrib.gis.geoip` test fallback (API removed in Django 3.0), and the async-API version guard in tests. Also fix issues surfaced while validating: - release workflow invoked setup.py, which no longer exists; build with python -m build instead - `migratesessions` used the Python 2-only e.message attribute - Makefile referenced django-admin.py, removed in Django 4.0 - example app was missing the request context processor required by the admin sidebar Test matrix is now Python 3.10-3.13 x Django 5.2/6.0/main.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #194 +/- ##
==========================================
+ Coverage 97.22% 98.48% +1.25%
==========================================
Files 24 25 +1
Lines 721 790 +69
Branches 56 31 -25
==========================================
+ Hits 701 778 +77
+ Misses 14 8 -6
+ Partials 6 4 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds tests for the uncovered paths: - `aset()` with a non-auth key - anonymous session and idempotent re-run
stereodamage
marked this pull request as ready for review
July 4, 2026 10:30
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add Django 5.2/6.0 support, drop EOL Django and Python versions
Closes #169, #188
Motivation and Context
The package currently supports Django 3.2 and 4.2, both of which have reached
end of extended support (April 2024 and April 2026 respectively, per the
supported versions table).
Meanwhile Django 5.1+ introduced changes that this package must adapt to —
one of which causes silent data loss in async views.
How Has This Been Tested?
Python 3.10–3.13 × Django 5.2 / 6.0 / main, with 3.10/3.11 excluded for
6.0+ (Django 6.0 requires Python 3.12+).
Full suite verified locally on Django 5.2 (Python 3.11) and Django 6.0
(Python 3.13), including a
-W error::DeprecationWarningrun — nodeprecation warnings on either.
Types of changes
Changes
Async session API support (bug fix)
Django 5.1 added an async API to all session backends
(
aget(),asave(),aload(), …), and Django 5.0 addedauth.alogin()and friends.Django's async
DBStoremethods do not delegate to their sync equivalents, sothis package's sync-only overrides were bypassed entirely in async code paths:
sessions saved via
alogin()or any async view were written withuser,user_agentandipallNULL— silently, since the model fields arenullable. This defeats the package's core purpose.
Fixed by mirroring the four sync overrides with async counterparts in
user_sessions.backends.db.SessionStore:aset()— capturesuser_id; notealogin()writes the session key viaaset(), bypassing__setitem___aget_session_from_db()— restoresuser_id, flagsmodifiedonuser-agent/IP change
acreate()— resets the session cacheacreate_model_instance()— persistsuser_agent,user_idandipCovered by new tests exercising the same call sequence
alogin()uses.GeoIP2 test fixtures
Django 5.1 changed
GeoIP2to open a single database,preferring the city database when available, so country lookups now hit the
city db. The city test fixture gained a country-only record for
8.8.8.8;the fixture generation stays compatible with the pre-5.1 lookup path.
Dropped versions (breaking)
Dead code removed accordingly: the
pkg_resourcesversion fallback, thedjango.contrib.gis.geoiptest fallback (API removed in Django 3.0), and aDjango version guard in tests.
Tooling fixes
setup.py, which no longer exists sincethe move to
pyproject.toml; it now builds withpython -m build(verified: artifacts build and pass
twine check)migratesessionsused the Python 2-onlye.messageattribute, raisingAttributeErroron any Python 3django-admin.py,removed in Django 4.0
requestcontext processor required by theadmin sidebar
Checklist: