Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Simple search form data normalization

Marcin Gębala1a17cfe7b64b
diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.py
index 1b3d10b685..2ad60d69df 100644
--- a/saleor/dashboard/customer/views.py
+++ b/saleor/dashboard/customer/views.py
@@ -43,6 +43,7 @@ class CustomerList(StaffMemberOnlyMixin, ListView, FormMixin):
return queryset
def apply_search_filters(self, queryset, data):
+ data = self._normalize_form_data(data)
if data['email']:
queryset = queryset.filter(email__icontains=data['email'])
if data['name']:
@@ -66,6 +67,11 @@ class CustomerList(StaffMemberOnlyMixin, ListView, FormMixin):
num_orders=Count('orders', distinct=True),
last_order=Max('orders', distinct=True))
+ def _normalize_form_data(self, data):
+ for k in data.keys():
+ data[k] = data[k].strip()
+ return data
+
class CustomerDetails(StaffMemberOnlyMixin, DetailView):
model = User