Skip to content

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

Move counting filters records from template to templatetag

michal27ec8c6e6f35
diff --git a/saleor/dashboard/templatetags/utils.py b/saleor/dashboard/templatetags/utils.py
index 4e81966760..36ebc1e99e 100644
--- a/saleor/dashboard/templatetags/utils.py
+++ b/saleor/dashboard/templatetags/utils.py
@@ -98,6 +98,7 @@ def add_filters(context, filter_set):
chips = handle_default(field, chips)
filter_context = {
'chips': chips,
- 'filter': filter_set
+ 'filter': filter_set,
+ 'count': filter_set.qs.count()
}
return filter_context
diff --git a/templates/dashboard/includes/_filters.html b/templates/dashboard/includes/_filters.html
index c0af53b6c0..a563ca07ac 100644
--- a/templates/dashboard/includes/_filters.html
+++ b/templates/dashboard/includes/_filters.html
@@ -8,7 +8,7 @@
<div class="card-content">
<div class="col s12">
<span class="card-title">{% trans 'Filters' context 'Dashboard card title' %}</span>
- <span>{% trans 'Total records found' context 'Dashboard filter' %}: {{ filter.qs|length }}</span>
+ <span>{% trans 'Total records found' context 'Dashboard filter' %}: {{ count }}</span>
<span class="collapse-activate hide-on-large-only"><svg data-src="{% static '/images/filter_icon.svg' %}" /></span>
</div>
<div class="col s12 hide-on-large-only chips-container">