Skip to content

Commit 4e1ff90

Browse files
committed
Added support for Django 4.2
Replaced the `index_together` model Meta option with `indexes` in `simple_history/models.py`, as the former has been deprecated (see https://docs.djangoproject.com/en/4.2/releases/4.2/#index-together-option-is-deprecated-in-favor-of-indexes). (This option has existed since before Django 3.2 - the minimum version we support.)
1 parent 83e3a0a commit 4e1ff90

File tree

9 files changed

+15
-3
lines changed

9 files changed

+15
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
15-
django-version: ['3.2', '4.1', 'main']
15+
django-version: ['3.2', '4.1', '4.2', 'main']
1616

1717
exclude:
1818
- python-version: '3.8'

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Unreleased
1313
- Support Urdu translation (gh-1199)
1414
- Dropped support for Python 3.7, which reached end-of-life on 2023-06-27 (gh-1202)
1515
- Dropped support for Django 4.0, which reached end-of-life on 2023-04-01 (gh-1202)
16+
- Added support for Django 4.2 (gh-1202)
1617

1718
3.3.0 (2023-03-08)
1819
------------------

README.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
3.2 3.8, 3.9, 3.10
4545
4.1 3.8, 3.9, 3.10, 3.11, 3.12-dev
46+
4.2 3.8, 3.9, 3.10, 3.11, 3.12-dev
4647
main 3.10, 3.11, 3.12-dev
4748
========== ========================
4849

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
3.2 3.8, 3.9, 3.10
4545
4.1 3.8, 3.9, 3.10, 3.11, 3.12-dev
46+
4.2 3.8, 3.9, 3.10, 3.11, 3.12-dev
4647
main 3.10, 3.11, 3.12-dev
4748
========== =======================
4849

requirements/postgres.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# DEV: Replace this with `psycopg[binary]` when the minimum required Django version is
2+
# 4.2 or higher, as this is likely to be deprecated in the future
3+
# (see https://docs.djangoproject.com/en/4.2/releases/4.2/#psycopg-3-support)
14
psycopg2-binary==2.9.6

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"Framework :: Django",
3939
"Framework :: Django :: 3.2",
4040
"Framework :: Django :: 4.1",
41+
"Framework :: Django :: 4.2",
4142
"Programming Language :: Python",
4243
"Programming Language :: Python :: 3",
4344
"Programming Language :: Python :: 3.8",

simple_history/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@ def get_meta_options(self, model):
625625
if self.app:
626626
meta_fields["app_label"] = self.app
627627
if self._date_indexing == "composite":
628-
meta_fields["index_together"] = (("history_date", model._meta.pk.attname),)
628+
meta_fields["indexes"] = (
629+
models.Index(fields=("history_date", model._meta.pk.attname)),
630+
)
629631
return meta_fields
630632

631633
def post_save(self, instance, created, using=None, **kwargs):

simple_history/tests/tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ class Foo(models.Model):
1414
history = HistoricalRecords()
1515

1616
self.assertEqual(
17-
("history_date", "id"), Foo.history.model._meta.index_together[0]
17+
["history_date", "id"], Foo.history.model._meta.indexes[0].fields
1818
)

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
envlist =
33
py{38,39,310}-dj32-{sqlite3,postgres,mysql,mariadb},
44
py{38,39,310,311,312}-dj41-{sqlite3,postgres,mysql,mariadb},
5+
py{38,39,310,311,312}-dj42-{sqlite3,postgres,mysql,mariadb},
56
py{310,311,312}-djmain-{sqlite3,postgres,mysql,mariadb},
67
docs,
78
lint
@@ -18,6 +19,7 @@ python =
1819
DJANGO =
1920
3.2: dj32
2021
4.1: dj41
22+
4.2: dj42
2123
main: djmain
2224

2325
[flake8]
@@ -31,6 +33,7 @@ deps =
3133
-rrequirements/test.txt
3234
dj32: Django>=3.2,<3.3
3335
dj41: Django>=4.1,<4.2
36+
dj42: Django>=4.2,<4.3
3437
djmain: https://github.com/django/django/tarball/main
3538
postgres: -rrequirements/postgres.txt
3639
mysql: -rrequirements/mysql.txt

0 commit comments

Comments
 (0)