From 3ae860dbcef967813419949a3c80c7abd4d71a54 Mon Sep 17 00:00:00 2001 From: d42 Date: Sat, 28 Apr 2018 20:44:47 +0200 Subject: [PATCH] smart search in parent select --- storage/views.py | 2 +- storage/widgets.py | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/storage/views.py b/storage/views.py index dafe2b4..b5ebec6 100644 --- a/storage/views.py +++ b/storage/views.py @@ -99,7 +99,7 @@ class ItemSelectView(AutoResponseView): def get(self, request, *args, **kwargs): self.widget = self.get_widget_or_404() self.term = kwargs.get('term', request.GET.get('term', '')) - self.object_list = self.get_queryset() + self.object_list = apply_smart_search(self.term, Item.objects) context = self.get_context_data() return JsonResponse({ 'results': [ diff --git a/storage/widgets.py b/storage/widgets.py index b887056..8c254d6 100644 --- a/storage/widgets.py +++ b/storage/widgets.py @@ -13,10 +13,6 @@ from django.contrib.admin.widgets import AdminTextareaWidget class ItemSelectWidget(ModelSelect2Widget): - search_fields = [ - 'name__icontains', - 'description__icontains' - ] def __init__(self, *args, **kwargs): kwargs['data_view'] = 'item-complete'