How it works...

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 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. For ratings, there is custom logic to filter movies that are between the selected rating and the one above, so anything greater than or equal to 8, but less than 9. Additionally, we set the selected values to the facets dictionary, which will be passed to the template.

In the template, for each categorization from the facets dictionary, we list all of the categories and mark the currently selected category as active. If nothing is selected for a given category, we mark the default "All" link as the active one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.168.8