March 2020
Intermediate to advanced
608 pages
17h 17m
English
We are using the facets dictionary that is passed to the template context to know which filters we have and which filters are selected. To look deeper, the facets dictionary consists of two sections: the categories dictionary and the selected dictionary. The categories dictionary contains QuerySets or choices of all filterable categories. The selected dictionary contains the currently selected values for each category. In IdeaFilterForm, we make sure that only those categories and authors are listed that have at least one idea.
In the view, we check whether the query parameters are valid in the form and then filter the QuerySet of objects based on the selected categories. Additionally, we set the selected values to the facets ...