Skip to content

Commit

Permalink
Added support for Django 5.1
Browse files Browse the repository at this point in the history
Also handled the deprecation of `get_cache_name()` - see https://docs.djangoproject.com/en/5.1/releases/5.1/#features-deprecated-in-5-1
  • Loading branch information
tim-schilling authored and ddabble committed Nov 24, 2024
1 parent 0ec991f commit da4c2f2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
django-version: ['4.2', '5.0', 'main']
django-version: ['4.2', '5.0', '5.1', 'main']

exclude:
# Exclude py3.9 for Django main and 5.0
# Exclude py3.9 for Django main and 5+
- python-version: '3.9'
django-version: '5.0'
- python-version: '3.9'
django-version: '5.1'
- python-version: '3.9'
django-version: 'main'

Expand Down Expand Up @@ -109,7 +111,7 @@ jobs:
# Install this project in editable mode, so that its package metadata can be queried
pip install -e .
# Install the latest minor version of Django we support
pip install Django==5.0
pip install Django==5.1
- name: Check translation files are updated
run: python -m simple_history.tests.generated_file_checks.check_translations
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased
- Added HistoricOneToOneField (gh-1394)
- Updated all djangoproject.com links to reference the stable version (gh-1420)
- Dropped support for Python 3.8, which reached end-of-life on 2024-10-07 (gh-1421)
- Added support for Django 5.1 (gh-1388)

3.7.0 (2024-05-29)
------------------
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This app supports the following combinations of Django and Python:
========== ========================
4.2 3.9, 3.10, 3.11, 3.12, 3.13
5.0 3.10, 3.11, 3.12, 3.13
5.1 3.10, 3.11, 3.12, 3.13
main 3.10, 3.11, 3.12, 3.13
========== ========================

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This app supports the following combinations of Django and Python:
========== =======================
4.2 3.9, 3.10, 3.11, 3.12, 3.13
5.0 3.10, 3.11, 3.12, 3.13
5.1 3.10, 3.11, 3.12, 3.13
main 3.10, 3.11, 3.12, 3.13
========== =======================

Expand Down
10 changes: 7 additions & 3 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,14 @@ def related_manager_cls(self):

class HistoricRelationModelManager(related_model._default_manager.__class__):
def get_queryset(self):
cache_name = (
# DEV: Remove this when support for Django 5.0 has been dropped
self.field.remote_field.get_cache_name()
if django.VERSION < (5, 1)
else self.field.remote_field.cache_name
)
try:
return self.instance._prefetched_objects_cache[
self.field.remote_field.get_cache_name()
]
return self.instance._prefetched_objects_cache[cache_name]
except (AttributeError, KeyError):
history = getattr(
self.instance, SIMPLE_HISTORY_REVERSE_ATTR_NAME, None
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[tox]
envlist =
py{39,310,311,312,313}-dj42-{sqlite3,postgres,mysql,mariadb},
py{310,311,312,313}-dj50-{sqlite3,postgres,mysql,mariadb},
py{310,311,312,313}-djmain-{sqlite3,postgres,mysql,mariadb},
py{310,311,312,313}-dj{50,51,main}-{sqlite3,postgres,mysql,mariadb},
docs,
lint

Expand All @@ -18,6 +17,7 @@ python =
DJANGO =
4.2: dj42
5.0: dj50
5.1: dj51
main: djmain

[flake8]
Expand All @@ -31,6 +31,7 @@ deps =
-rrequirements/test.txt
dj42: Django>=4.2,<4.3
dj50: Django>=5.0,<5.1
dj51: Django>=5.1,<5.2
djmain: https://github.com/django/django/tarball/main
postgres: -rrequirements/postgres.txt
mysql: -rrequirements/mysql.txt
Expand Down

0 comments on commit da4c2f2

Please sign in to comment.