Невозможно передать контекстные данные Django в представление HTML

Кто-нибудь может подсказать мне, как я могу передать контекстные данные в представление. Я ничего не получаю на HTML-странице.

views.py def cart(request): if request.method == 'POST': return redirect('index')

else:
    if request.method == 'GET':
        # Recieve local storage product in post_id varibale
        post_id = request.GET.get('get_cart')
        cat_product = Product.objects.filter(id=.11)
        if post_id is not None:
        # Fomrat and remove { } and " from  post_id string
            post_id = post_id.replace('{','')
            post_id = post_id.replace('}','')
            post_id = post_id.replace('"','')
            print("The Id is", post_id )
        # Find ':' in string and get the value of id in cart_prod_index
            index =0
            while index < len(post_id):
                index = post_id.find(':', index)
                if index == -1:
                    break
                local_storage_prod_id = post_id[index-1]

                # '|' operator is used to append the queryset result

                cat_product = cat_product | Product.objects.filter(id=local_storage_prod_id)
            
                index+=2
        print(cat_product)
        return render(request, "cart.html" ,{"x":cat_product,})
   

В cart.html

 {% for search in x %}
                     {{search.name}}
            {% endfor %}

Пожалуйста, скажите, как я могу получить набор запросов в HTML-странице

?
Вернуться на верх