Skip to content

Commit 82cd898

Browse files
authored
fix: autocomplete in django 5.0 (#253)
* fix: autocomplete in django 5.0 * fix(ci): don't use multiple processes for tests
1 parent 623c5ba commit 82cd898

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
8787
- name: Run tests
8888
run: |
89-
tox -- -vvv --selenosis-driver=chrome-headless --numprocesses=4 --exitfirst || \
89+
tox -- -vvv --selenosis-driver=chrome-headless || \
9090
tox -- -vvv --selenosis-driver=chrome-headless
9191
env:
9292
PIXELMATCH_BIN: ${{ env.GITHUB_WORKSPACE }}/node_modules/.bin/pixelmatch

nested_admin/compat.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
See https://github.com/django/django/commit/c19b56f633e172b3c02094cbe12d28865ee57772
55
and https://code.djangoproject.com/ticket/28377
66
"""
7+
78
from collections import defaultdict, OrderedDict
89
import warnings
910

@@ -23,17 +24,23 @@ class MediaOrderConflictWarning(RuntimeWarning):
2324
MergeSafeMedia = django.forms.Media
2425

2526
try:
26-
from django.utils.topological_sort import (
27+
from django.utils.topological_sort import ( # noqa: F401
2728
CyclicDependencyError,
2829
stable_topological_sort,
2930
)
31+
32+
has_topological_sort = True
3033
except ImportError:
34+
try:
35+
from django.forms.widgets import TopologicalSorter # noqa: F401
36+
except ImportError:
37+
has_topological_sort = False
38+
else:
39+
has_topological_sort = True
3140

3241
class CyclicDependencyError(ValueError):
3342
pass
3443

35-
stable_topological_sort = None
36-
3744

3845
class OrderedSet(_OrderedSet):
3946
def __sub__(self, other):
@@ -46,7 +53,7 @@ def __repr__(self):
4653
return "OrderedSet(%r)" % list(self)
4754

4855

49-
if MergeSafeMedia is None or stable_topological_sort is None:
56+
if MergeSafeMedia is None or not has_topological_sort:
5057

5158
def linearize_as_needed(l, dependency_graph):
5259
# Algorithm: DFS Topological sort

nested_admin/tests/admin_widgets/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ def test_nested_autocomplete_extra(self):
406406
self.add_inline([0, 1, [0]])
407407
select_field = self.get_field("fk3", indexes=[0, 1, [0, 0]])
408408
select_parent = select_field.find_element(By.XPATH, "parent::*")
409-
select_parent.click()
409+
self.selenium.execute_script(
410+
"return arguments[0].querySelector('.select2-selection') || arguments[0]",
411+
select_parent,
412+
).click()
413+
410414
select2_is_active = self.selenium.execute_script(
411415
'return $(".select2-search__field").length > 0'
412416
)

0 commit comments

Comments
 (0)