def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) categories = Category.get_categories_with_dishes() order = Order.get_current_temp_order(self.request.session) context['current_category'] = self.category context['categories'] = categories context['order'] = order return context
def run(request): categories = Category.get_categories_with_dishes() dishes = Dish.objects.filter(is_draft=False) order = Order.get_current_temp_order(request.session) if order: for dish in dishes: dish_in_order = order.order_dish.filter(dish=dish).first() if dish_in_order: dish.count = dish_in_order.count return render(request, 'catalog/index.html', context={ 'categories': categories, 'dishes': dishes, 'order': order })