Skip to contentSkip to conversation

toaster: fix typo which causes table searches to fail

PATCH New Michael Wood 1 participant 1 message Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: fix typo which causes table searches to fail

From: Elliot Smith <[email protected]>

The iterator used to create a search query refers to a variable "x" which isn't set, causing an "'x' is not defined" error and preventing table searches (on non-ToasterTables) from working.

Use the "field" variable instead, which contains the name of the field to add to the query.

[YOCTO #9749]

---
 lib/toaster/toastergui/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/toaster/toastergui/views.py +1 -1
index 0254876..28ff67b 100755
@@ -324,7 +324,7 @@ def _get_search_results(search_term, queryset, model):
     for st in search_term.split(" "):
         queries = None
         for field in model.search_allowed_fields:
-            query =  Q(**{x+'__icontains': st})
+            query = Q(**{field + '__icontains': st})
             queries = queries | query if queries else query
 
         search_object = search_object & queries if search_object else queries
Signature · 1 line
2.7.4