Пример #1
0
 def get_context_data(self, **kwargs):
     context = super(SearchView, self).get_context_data(**kwargs)
     context["form"] = self.form
     products = context["products"]
     if products:
         products = cache_product_things(self.request, products)
         products = sort_products(self.request, products, self.form.cleaned_data.get("sort"))
         products = [p for p in products if is_visible({"request": self.request}, p)]
         context["products"] = products
     context["no_results"] = (self.form.is_valid() and not products)
     return context
Пример #2
0
 def get_context_data(self, **kwargs):
     context = super(SearchView, self).get_context_data(**kwargs)
     context["form"] = self.form
     products = context["products"]
     if products:
         products = cache_product_things(self.request, products)
         products = sort_products(self.request, products, self.form.cleaned_data.get("sort"))
         products = [p for p in products if is_visible({"request": self.request}, p)]
         context["products"] = products
     context["no_results"] = (self.form.is_valid() and not products)
     return context