Skip to content

Commit fb9d52c

Browse files
committed
Prepare for Django 5.x support
1 parent e254a68 commit fb9d52c

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| :memo: | **License** | [![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org) |
99
| :package: | **PyPi** | [![PyPi](https://badge.fury.io/py/django-postgres-extra.svg)](https://pypi.python.org/pypi/django-postgres-extra) |
1010
| :four_leaf_clover: | **Code coverage** | [![Coverage Status](https://coveralls.io/repos/github/SectorLabs/django-postgres-extra/badge.svg?branch=coveralls)](https://coveralls.io/github/SectorLabs/django-postgres-extra?branch=master) |
11-
| <img src="https://cdn.iconscout.com/icon/free/png-256/django-1-282754.png" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2 |
11+
| <img src="https://cdn.iconscout.com/icon/free/png-256/django-1-282754.png" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0 |
1212
| <img src="https://cdn3.iconfinder.com/data/icons/logos-and-brands-adobe/512/267_Python-512.png" width="22px" height="22px" align="center" /> | **Python Versions** | 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 |
1313
| <img src="https://pbs.twimg.com/profile_images/1152122059/psycopg-100_400x400.png" width="22px" height="22px" align="center" /> | **Psycopg Versions** | 2, 3 |
1414
| :book: | **Documentation** | [Read The Docs](https://django-postgres-extra.readthedocs.io/en/master/) |

psqlextra/sql.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ def rename_annotations(self, annotations) -> None:
6464
new_annotations[new_name or old_name] = annotation
6565

6666
if new_name and self.annotation_select_mask:
67-
self.annotation_select_mask.discard(old_name)
68-
self.annotation_select_mask.add(new_name)
67+
# It's a set in all versions prior to Django 5.x
68+
# and a list in Django 5.x and newer.
69+
# https://github.com/django/django/commit/d6b6e5d0fd4e6b6d0183b4cf6e4bd4f9afc7bf67
70+
if isinstance(self.annotation_select_mask, set):
71+
self.annotation_select_mask.discard(old_name)
72+
self.annotation_select_mask.add(new_name)
73+
elif isinstance(self.annotation_select_mask, list):
74+
self.annotation_select_mask.remove(old_name)
75+
self.annotation_select_mask.append(new_name)
6976

7077
self.annotations.clear()
7178
self.annotations.update(new_annotations)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def run(self):
6868
],
6969
python_requires=">=3.6",
7070
install_requires=[
71-
"Django>=2.0,<5.0",
71+
"Django>=2.0,<6.0",
7272
"python-dateutil>=2.8.0,<=3.0.0",
7373
],
7474
extras_require={

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ envlist =
33
{py36,py37}-dj{20,21,22,30,31,32}-psycopg{28,29}
44
{py38,py39,py310}-dj{21,22,30,31,32,40}-psycopg{28,29}
55
{py38,py39,py310,py311}-dj{41}-psycopg{28,29}
6-
{py38,py39,py310,py311}-dj{42}-psycopg{28,29,31}
6+
{py310,py311}-dj{42,50}-psycopg{28,29,31}
77

88
[testenv]
99
deps =
@@ -16,6 +16,7 @@ deps =
1616
dj40: Django~=4.0.0
1717
dj41: Django~=4.1.0
1818
dj42: Django~=4.2.0
19+
dj50: Django~=5.0.1
1920
psycopg28: psycopg2[binary]~=2.8
2021
psycopg29: psycopg2[binary]~=2.9
2122
psycopg31: psycopg[binary]~=3.1

0 commit comments

Comments
 (0)