Skip to content

Commit da4c2f2

Browse files
tim-schillingddabble
authored andcommitted
Added support for Django 5.1
Also handled the deprecation of `get_cache_name()` - see https://docs.djangoproject.com/en/5.1/releases/5.1/#features-deprecated-in-5-1
1 parent 0ec991f commit da4c2f2

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
15-
django-version: ['4.2', '5.0', 'main']
15+
django-version: ['4.2', '5.0', '5.1', 'main']
1616

1717
exclude:
18-
# Exclude py3.9 for Django main and 5.0
18+
# Exclude py3.9 for Django main and 5+
1919
- python-version: '3.9'
2020
django-version: '5.0'
21+
- python-version: '3.9'
22+
django-version: '5.1'
2123
- python-version: '3.9'
2224
django-version: 'main'
2325

@@ -109,7 +111,7 @@ jobs:
109111
# Install this project in editable mode, so that its package metadata can be queried
110112
pip install -e .
111113
# Install the latest minor version of Django we support
112-
pip install Django==5.0
114+
pip install Django==5.1
113115
114116
- name: Check translation files are updated
115117
run: python -m simple_history.tests.generated_file_checks.check_translations

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Unreleased
1111
- Added HistoricOneToOneField (gh-1394)
1212
- Updated all djangoproject.com links to reference the stable version (gh-1420)
1313
- Dropped support for Python 3.8, which reached end-of-life on 2024-10-07 (gh-1421)
14+
- Added support for Django 5.1 (gh-1388)
1415

1516
3.7.0 (2024-05-29)
1617
------------------

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This app supports the following combinations of Django and Python:
4747
========== ========================
4848
4.2 3.9, 3.10, 3.11, 3.12, 3.13
4949
5.0 3.10, 3.11, 3.12, 3.13
50+
5.1 3.10, 3.11, 3.12, 3.13
5051
main 3.10, 3.11, 3.12, 3.13
5152
========== ========================
5253

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ This app supports the following combinations of Django and Python:
4343
========== =======================
4444
4.2 3.9, 3.10, 3.11, 3.12, 3.13
4545
5.0 3.10, 3.11, 3.12, 3.13
46+
5.1 3.10, 3.11, 3.12, 3.13
4647
main 3.10, 3.11, 3.12, 3.13
4748
========== =======================
4849

simple_history/models.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,10 +899,14 @@ def related_manager_cls(self):
899899

900900
class HistoricRelationModelManager(related_model._default_manager.__class__):
901901
def get_queryset(self):
902+
cache_name = (
903+
# DEV: Remove this when support for Django 5.0 has been dropped
904+
self.field.remote_field.get_cache_name()
905+
if django.VERSION < (5, 1)
906+
else self.field.remote_field.cache_name
907+
)
902908
try:
903-
return self.instance._prefetched_objects_cache[
904-
self.field.remote_field.get_cache_name()
905-
]
909+
return self.instance._prefetched_objects_cache[cache_name]
906910
except (AttributeError, KeyError):
907911
history = getattr(
908912
self.instance, SIMPLE_HISTORY_REVERSE_ATTR_NAME, None

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[tox]
22
envlist =
33
py{39,310,311,312,313}-dj42-{sqlite3,postgres,mysql,mariadb},
4-
py{310,311,312,313}-dj50-{sqlite3,postgres,mysql,mariadb},
5-
py{310,311,312,313}-djmain-{sqlite3,postgres,mysql,mariadb},
4+
py{310,311,312,313}-dj{50,51,main}-{sqlite3,postgres,mysql,mariadb},
65
docs,
76
lint
87

@@ -18,6 +17,7 @@ python =
1817
DJANGO =
1918
4.2: dj42
2019
5.0: dj50
20+
5.1: dj51
2121
main: djmain
2222

2323
[flake8]
@@ -31,6 +31,7 @@ deps =
3131
-rrequirements/test.txt
3232
dj42: Django>=4.2,<4.3
3333
dj50: Django>=5.0,<5.1
34+
dj51: Django>=5.1,<5.2
3435
djmain: https://github.com/django/django/tarball/main
3536
postgres: -rrequirements/postgres.txt
3637
mysql: -rrequirements/mysql.txt

0 commit comments

Comments
 (0)