From 85fe3137b40020a07adcb0733be5838d59aee269 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 10:35:16 +0000 Subject: [PATCH 01/13] Test against python 12 and 13 --- .github/workflows/ci.yml | 2 ++ pyproject.toml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af48ff49..e9e3a4be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,8 @@ jobs: - "3.9" - "3.10" - "3.11" + - "3.12" + - "3.13" django-version: - "3.2" - "4.1" diff --git a/pyproject.toml b/pyproject.toml index d6ce5548..4eccd74e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,8 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Framework :: Django", "Framework :: Django :: 3.2", "Framework :: Django :: 4.1", From 7c46e8376eb76dd15730f294514892cc47a4d4b9 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 10:37:11 +0000 Subject: [PATCH 02/13] Test against django 5.0 and 5.1 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9e3a4be..c07840d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,8 @@ jobs: - "3.2" - "4.1" - "4.2" + - "5.0" + - "5.1" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 272ead51893c8ca19b0c40c7547a6a52baeb621a Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 10:38:11 +0000 Subject: [PATCH 03/13] Bump version of node used for standardjs test to 22 (LTS) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c07840d0..ea49c673 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '12.x' + node-version: '22.x' - run: npm install -g standard - run: standard From 145ca663a66b24820ef8c78e79d0a645b681923c Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 10:43:12 +0000 Subject: [PATCH 04/13] Only test supported versions of django --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea49c673..d0401baf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,8 +73,6 @@ jobs: - "3.12" - "3.13" django-version: - - "3.2" - - "4.1" - "4.2" - "5.0" - "5.1" From 26cdcef574e0b4810de25f4a98249c86922cf03e Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 10:51:48 +0000 Subject: [PATCH 05/13] Add exclude matrix to tests and don't test py 3.8 (EOL) --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0401baf..6970b7e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,6 @@ jobs: strategy: matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" @@ -76,6 +75,13 @@ jobs: - "4.2" - "5.0" - "5.1" + exclude: + - django-version: "4.2" + python-version: ["3.13"] + - django-version: "5.0" + python-version: ["3.9", "3.13"] + - django-version: "5.1" + python-version: ["3.9"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From d54277c055677e3160d1016e46e6060c32a1ad54 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 11:01:48 +0000 Subject: [PATCH 06/13] Fix exclude matrix --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6970b7e3..eb453f8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,12 +76,15 @@ jobs: - "5.0" - "5.1" exclude: + # See https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django - django-version: "4.2" - python-version: ["3.13"] + python-version: "3.13" - django-version: "5.0" - python-version: ["3.9", "3.13"] + python-version: "3.9" + - django-version: "5.0" + python-version: "3.13" - django-version: "5.1" - python-version: ["3.9"] + python-version: "3.9" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From f7fae30a97cfcf183375d3c5c344354819f6a307 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 11:04:13 +0000 Subject: [PATCH 07/13] Update pyproject to drop support for EOL python and django --- pyproject.toml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4eccd74e..f1f24cf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,21 +20,20 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.1", "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", + "Framework :: Django :: 5.1", "Topic :: Software Development", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ - "django>=3.2", + "django>=4.2", "django-appconf>=0.6.0" ] From 3dce5b62ad63981f155d21c702c57140c4d21c32 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 11:15:16 +0000 Subject: [PATCH 08/13] Drop old django code --- django_select2/forms.py | 19 +++---------------- example/example/settings.py | 1 - tests/test_forms.py | 22 ---------------------- tests/test_views.py | 6 +----- tests/testapp/settings.py | 4 ---- 5 files changed, 4 insertions(+), 48 deletions(-) diff --git a/django_select2/forms.py b/django_select2/forms.py index 85f84672..6c5e191e 100644 --- a/django_select2/forms.py +++ b/django_select2/forms.py @@ -60,8 +60,8 @@ from itertools import chain from pickle import PicklingError # nosec -import django from django import forms +from django.contrib.admin.utils import lookup_spawns_duplicates from django.contrib.admin.widgets import AutocompleteMixin from django.core import signing from django.db.models import Q @@ -71,13 +71,6 @@ from .cache import cache from .conf import settings -if django.VERSION < (4, 0): - from django.contrib.admin.utils import ( - lookup_needs_distinct as lookup_spawns_duplicates, - ) -else: - from django.contrib.admin.utils import lookup_spawns_duplicates - class Select2Mixin: """ @@ -96,15 +89,9 @@ class Select2Mixin: @property def i18n_name(self): """Name of the i18n file for the current language.""" - if django.VERSION < (4, 1): - from django.contrib.admin.widgets import SELECT2_TRANSLATIONS - from django.utils.translation import get_language - - return SELECT2_TRANSLATIONS.get(get_language()) - else: - from django.contrib.admin.widgets import get_select2_language + from django.contrib.admin.widgets import get_select2_language - return get_select2_language() + return get_select2_language() def build_attrs(self, base_attrs, extra_attrs=None): """Add select2 data attributes.""" diff --git a/example/example/settings.py b/example/example/settings.py index 6eef77a3..d35ea1ff 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -105,7 +105,6 @@ USE_I18N = True -USE_L10N = True USE_TZ = True diff --git a/tests/test_forms.py b/tests/test_forms.py index 71b0b042..afe53f70 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -2,7 +2,6 @@ import os from collections.abc import Iterable -import django import pytest from django.db.models import QuerySet from django.urls import reverse @@ -851,7 +850,6 @@ def widget_fixture(request): return widget_class(**widget_kwargs) -@pytest.mark.skipif(django.VERSION < (4, 1), reason="Only for Django 4.1+") @pytest.mark.parametrize( "locale,expected", [ @@ -868,7 +866,6 @@ def test_i18n_name_property_with_country_code_in_locale(widget, locale, expected assert widget.i18n_name == expected -@pytest.mark.skipif(django.VERSION < (4, 1), reason="Only for Django 4.1+") def test_i18n_media_js_with_country_code_in_locale(widget): translation.activate("fr-FR") assert tuple(widget.media._js) == ( @@ -878,28 +875,9 @@ def test_i18n_media_js_with_country_code_in_locale(widget): ) -@pytest.mark.skipif(django.VERSION >= (4, 1), reason="Only for Django 4.0 and previous") -@pytest.mark.parametrize( - "locale,expected", - [ - ("fr-FR", None), - # Some locales with a country code are natively supported by select2's i18n - ("pt-BR", "pt-BR"), - ("sr-Cyrl", "sr-Cyrl"), - ], -) def test_i18n_name_property_with_country_code_in_locale_for_older_django( widget, locale, expected ): """No fallback for locale with an unsupported country code.""" with translation.override(locale): assert widget.i18n_name == expected - - -@pytest.mark.skipif(django.VERSION >= (4, 1), reason="Only for Django 4.0 and previous") -def test_i18n_media_js_with_country_code_in_locale_for_older_django(widget): - translation.activate("fr-FR") - assert tuple(widget.media._js) == ( - "admin/js/vendor/select2/select2.full.min.js", - "django_select2/django_select2.js", - ) diff --git a/tests/test_views.py b/tests/test_views.py index 745dbfad..b1bf8a46 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,5 +1,6 @@ import json +from django.urls import reverse from django.utils.encoding import smart_str from django_select2.cache import cache @@ -11,11 +12,6 @@ ) from tests.testapp.models import Genre -try: - from django.urls import reverse -except ImportError: - from django.core.urlresolvers import reverse - class TestAutoResponseView: def test_get(self, client, artists): diff --git a/tests/testapp/settings.py b/tests/testapp/settings.py index f6673aa9..09d58dfb 100644 --- a/tests/testapp/settings.py +++ b/tests/testapp/settings.py @@ -1,7 +1,5 @@ import os.path -import django - BASE_DIR = os.path.dirname(os.path.abspath(__file__)) DEBUG = True @@ -40,7 +38,5 @@ SECRET_KEY = "123456" -if django.VERSION < (4, 0): - USE_L10N = True USE_I18N = True USE_TZ = True From ac53e28fc18799f08f9d101c602ac017a4a55b7f Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 11:20:10 +0000 Subject: [PATCH 09/13] Remove uneeded test --- tests/test_forms.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_forms.py b/tests/test_forms.py index afe53f70..313bb838 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -873,11 +873,3 @@ def test_i18n_media_js_with_country_code_in_locale(widget): "admin/js/vendor/select2/i18n/fr.js", "django_select2/django_select2.js", ) - - -def test_i18n_name_property_with_country_code_in_locale_for_older_django( - widget, locale, expected -): - """No fallback for locale with an unsupported country code.""" - with translation.override(locale): - assert widget.i18n_name == expected From 1df6a896efac6ff4fc29687c11e8f2fdfa8044f0 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 11:26:26 +0000 Subject: [PATCH 10/13] Tidy up whitespace in example settings.py --- example/example/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/example/example/settings.py b/example/example/settings.py index d35ea1ff..7fed8450 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -105,7 +105,6 @@ USE_I18N = True - USE_TZ = True From 612064ac2e0f31f5ab973840544fe28c0897d9e0 Mon Sep 17 00:00:00 2001 From: Mike Manger Date: Fri, 7 Feb 2025 13:12:44 +0000 Subject: [PATCH 11/13] Fix typo in tests file comment. --- tests/test_forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_forms.py b/tests/test_forms.py index 313bb838..c42d457f 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -750,7 +750,7 @@ def test_widgets_selected_after_validation_error( assert len(city_names_from_browser) != City.objects.count() assert city_names_from_browser == city_names_from_db - # selecting a city reaaly does it + # selecting a city really does it city_option = driver.find_element( By.CSS_SELECTOR, ".select2-results li:nth-child(2)" ) From b03ec7b634d42e366876d4764e32fee6370b7c00 Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Sun, 9 Feb 2025 15:32:10 +0100 Subject: [PATCH 12/13] Update .nvmrc for npm version control --- .github/workflows/ci.yml | 2 +- .nvmrc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .nvmrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb453f8b..f0a73f82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '22.x' + node-version-file: '.nvmrc' - run: npm install -g standard - run: standard diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b009dfb9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* From 23eb07fa85d72276c4fd98b18ac03a3a5379c41c Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Sun, 9 Feb 2025 15:36:27 +0100 Subject: [PATCH 13/13] Drop py9 and dj50 --- .github/workflows/ci.yml | 12 ------------ pyproject.toml | 4 +--- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0a73f82..7438534a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,25 +66,13 @@ jobs: strategy: matrix: python-version: - - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" django-version: - "4.2" - - "5.0" - "5.1" - exclude: - # See https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django - - django-version: "4.2" - python-version: "3.13" - - django-version: "5.0" - python-version: "3.9" - - django-version: "5.0" - python-version: "3.13" - - django-version: "5.1" - python-version: "3.9" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index f1f24cf5..2f0ff4da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,18 +20,16 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Framework :: Django", "Framework :: Django :: 4.2", - "Framework :: Django :: 5.0", "Framework :: Django :: 5.1", "Topic :: Software Development", ] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "django>=4.2", "django-appconf>=0.6.0"