mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-03-17 05:50:23 +00:00
Fixed -- IndexError: pop from empty list
This commit is contained in:
parent
a91e66bf9e
commit
2c1eb8bc4a
3 changed files with 9 additions and 2 deletions
|
|
@ -9,4 +9,4 @@ The app includes Select2 driven Django Widgets and Form Fields.
|
|||
|
||||
"""
|
||||
|
||||
__version__ = "5.1.0"
|
||||
__version__ = "5.1.1"
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ class ModelSelect2Mixin(object):
|
|||
term = term.replace('\n', ' ')
|
||||
for t in [t for t in term.split(' ') if not t == '']:
|
||||
select &= reduce(lambda x, y: x | Q(**{y: t}), search_fields,
|
||||
Q(**{search_fields.pop(): t}))
|
||||
Q(**{search_fields[0]: t}))
|
||||
return queryset.filter(select).distinct()
|
||||
|
||||
def get_queryset(self):
|
||||
|
|
|
|||
|
|
@ -154,6 +154,13 @@ class TestModelSelect2Mixin(TestHeavySelect2Mixin):
|
|||
widget = TitleModelSelect2Widget(queryset=Genre.objects.all())
|
||||
assert widget.filter_queryset(genres[0].title[:3]).exists()
|
||||
|
||||
widget = TitleModelSelect2Widget(search_fields=['title__icontains'],
|
||||
queryset=Genre.objects.all())
|
||||
qs = widget.filter_queryset(" ".join([genres[0].title[:3], genres[0].title[3:]]))
|
||||
assert qs.exists()
|
||||
|
||||
|
||||
|
||||
def test_model_kwarg(self):
|
||||
widget = ModelSelect2Widget(model=Genre, search_fields=['title__icontains'])
|
||||
genre = Genre.objects.last()
|
||||
|
|
|
|||
Loading…
Reference in a new issue