def category(request, category, context, **kwargs): query = QueryString(request) # Pass queryset through product module and include http query # for further filtering and sorting products = modules.product.list(request, category=category, query=query) # Get root category if not category.is_leaf_node(): root = category elif category.is_child_node(): root = category.parent else: root = category products = paginate(request, products) product_filters = modules.product.get_filters(request, products.object_list.facets(), category=category, query=query) context.update({ 'products': products, 'product_filters': product_filters, 'root': root, 'category': category, 'q': query }) return render(request, 'category/category.html', context)
def category(request, category, context, **kwargs): qs = QueryString(request) # Query all products in this category products = modules.product.Product.objects.in_category(category).polymorphic() # Pass queryset through product module and include http query # for further filtering and sorting products = modules.product.list(request=request, products=products, query=qs) # Get root category if not category.is_leaf_node(): root = category elif category.is_child_node(): root = category.parent else: root = category context.update({ 'products': paginate(request, products), 'root': root, 'category': category, 'index': getattr(products, 'index', None), 'qs': qs }) return render(request, 'category/category.html', context)
def _category(request, category, **kwargs): query = QueryString(request) # Pass queryset through product module and include http query # for further filtering and sorting products = list_products_from_request(request, category=category, query=query) # Get root category if not category.is_leaf_node(): root = category elif category.is_child_node(): root = category.parent else: root = category products = paginate(request, products) product_filters = product_filters_from_request(request, products.object_list.facets(), category=category, query=query) yield TemplateResponse(request, 'category/category.html', { 'products': products, 'product_filters': product_filters, 'root': root, 'category': category, 'q': query })
def search(request, context=None, **kwargs): if context is None: context = {} query = QueryString(request) context.update({'q': query}) if SEARCH_URL_PARAM in query and query[SEARCH_URL_PARAM]: products = list_products_from_request(request, query=query) products = paginate(request, products) product_filters = product_filters_from_request( request, products.object_list.facets(), query=query) context.update({ 'products': products, 'product_filters': product_filters, }) return TemplateResponse(request, 'search/search.html', context)
def search(request, context=None, **kwargs): if context is None: context = {} query = QueryString(request) context.update({ 'q': query }) if SEARCH_URL_PARAM in query and query[SEARCH_URL_PARAM]: products = list_products_from_request(request, query=query) products = paginate(request, products) product_filters = product_filters_from_request(request, products.object_list.facets(), query=query) context.update({ 'products': products, 'product_filters': product_filters, }) return TemplateResponse(request, 'search/search.html', context)