Skip to content

Commit 3dce5b6

Browse files
committed
Drop old django code
1 parent f7fae30 commit 3dce5b6

File tree

5 files changed

+4
-48
lines changed

5 files changed

+4
-48
lines changed

django_select2/forms.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
from itertools import chain
6161
from pickle import PicklingError # nosec
6262

63-
import django
6463
from django import forms
64+
from django.contrib.admin.utils import lookup_spawns_duplicates
6565
from django.contrib.admin.widgets import AutocompleteMixin
6666
from django.core import signing
6767
from django.db.models import Q
@@ -71,13 +71,6 @@
7171
from .cache import cache
7272
from .conf import settings
7373

74-
if django.VERSION < (4, 0):
75-
from django.contrib.admin.utils import (
76-
lookup_needs_distinct as lookup_spawns_duplicates,
77-
)
78-
else:
79-
from django.contrib.admin.utils import lookup_spawns_duplicates
80-
8174

8275
class Select2Mixin:
8376
"""
@@ -96,15 +89,9 @@ class Select2Mixin:
9689
@property
9790
def i18n_name(self):
9891
"""Name of the i18n file for the current language."""
99-
if django.VERSION < (4, 1):
100-
from django.contrib.admin.widgets import SELECT2_TRANSLATIONS
101-
from django.utils.translation import get_language
102-
103-
return SELECT2_TRANSLATIONS.get(get_language())
104-
else:
105-
from django.contrib.admin.widgets import get_select2_language
92+
from django.contrib.admin.widgets import get_select2_language
10693

107-
return get_select2_language()
94+
return get_select2_language()
10895

10996
def build_attrs(self, base_attrs, extra_attrs=None):
11097
"""Add select2 data attributes."""

example/example/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105

106106
USE_I18N = True
107107

108-
USE_L10N = True
109108

110109
USE_TZ = True
111110

tests/test_forms.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
from collections.abc import Iterable
44

5-
import django
65
import pytest
76
from django.db.models import QuerySet
87
from django.urls import reverse
@@ -851,7 +850,6 @@ def widget_fixture(request):
851850
return widget_class(**widget_kwargs)
852851

853852

854-
@pytest.mark.skipif(django.VERSION < (4, 1), reason="Only for Django 4.1+")
855853
@pytest.mark.parametrize(
856854
"locale,expected",
857855
[
@@ -868,7 +866,6 @@ def test_i18n_name_property_with_country_code_in_locale(widget, locale, expected
868866
assert widget.i18n_name == expected
869867

870868

871-
@pytest.mark.skipif(django.VERSION < (4, 1), reason="Only for Django 4.1+")
872869
def test_i18n_media_js_with_country_code_in_locale(widget):
873870
translation.activate("fr-FR")
874871
assert tuple(widget.media._js) == (
@@ -878,28 +875,9 @@ def test_i18n_media_js_with_country_code_in_locale(widget):
878875
)
879876

880877

881-
@pytest.mark.skipif(django.VERSION >= (4, 1), reason="Only for Django 4.0 and previous")
882-
@pytest.mark.parametrize(
883-
"locale,expected",
884-
[
885-
("fr-FR", None),
886-
# Some locales with a country code are natively supported by select2's i18n
887-
("pt-BR", "pt-BR"),
888-
("sr-Cyrl", "sr-Cyrl"),
889-
],
890-
)
891878
def test_i18n_name_property_with_country_code_in_locale_for_older_django(
892879
widget, locale, expected
893880
):
894881
"""No fallback for locale with an unsupported country code."""
895882
with translation.override(locale):
896883
assert widget.i18n_name == expected
897-
898-
899-
@pytest.mark.skipif(django.VERSION >= (4, 1), reason="Only for Django 4.0 and previous")
900-
def test_i18n_media_js_with_country_code_in_locale_for_older_django(widget):
901-
translation.activate("fr-FR")
902-
assert tuple(widget.media._js) == (
903-
"admin/js/vendor/select2/select2.full.min.js",
904-
"django_select2/django_select2.js",
905-
)

tests/test_views.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22

3+
from django.urls import reverse
34
from django.utils.encoding import smart_str
45

56
from django_select2.cache import cache
@@ -11,11 +12,6 @@
1112
)
1213
from tests.testapp.models import Genre
1314

14-
try:
15-
from django.urls import reverse
16-
except ImportError:
17-
from django.core.urlresolvers import reverse
18-
1915

2016
class TestAutoResponseView:
2117
def test_get(self, client, artists):

tests/testapp/settings.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os.path
22

3-
import django
4-
53
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
64
DEBUG = True
75

@@ -40,7 +38,5 @@
4038

4139
SECRET_KEY = "123456"
4240

43-
if django.VERSION < (4, 0):
44-
USE_L10N = True
4541
USE_I18N = True
4642
USE_TZ = True

0 commit comments

Comments
 (0)