diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af48ff49..7438534a 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-file: '.nvmrc' - run: npm install -g standard - run: standard @@ -66,14 +66,13 @@ jobs: strategy: matrix: python-version: - - "3.8" - - "3.9" - "3.10" - "3.11" + - "3.12" + - "3.13" django-version: - - "3.2" - - "4.1" - "4.2" + - "5.1" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b009dfb9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* 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..7fed8450 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -105,8 +105,6 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True diff --git a/pyproject.toml b/pyproject.toml index d6ce5548..2f0ff4da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,19 +20,18 @@ 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.1", "Topic :: Software Development", ] -requires-python = ">=3.8" +requires-python = ">=3.10" dependencies = [ - "django>=3.2", + "django>=4.2", "django-appconf>=0.6.0" ] diff --git a/tests/test_forms.py b/tests/test_forms.py index 71b0b042..c42d457f 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 @@ -751,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)" ) @@ -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) == ( @@ -876,30 +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", ) - - -@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