Closed ziom1555 closed 3 years ago
my base.html: `{% load static %} <!DOCTYPE html>
Kontynuuj zakupy Do kasy
I solved the problem. In the base.html file, I had spaces in the line:
<a href=" replies "cart: cart_detail"% inc"> after the word "cart:"
Correct spelling without spaces. There must be no spaces after the word "cart:". Correct ruler:
<a href=" replies "cart: cart_detail"% inc">
Exactly, there should be no spaces in cart:cart_detail. The code should look like this:
cart:cart_detail
<a href="{% url "cart:cart_detail" %}"> {{ total_items }} item{{ total_items|pluralize }}, ${{ cart.get_total_price }} </a>
my base.html: `{% load static %} <!DOCTYPE html>
Koszyk na zakupy
Kontynuuj zakupy Do kasy
{% endblock %}` cart/views.py: `from django.shortcuts import render, redirect, get_object_or_404 from django.views.decorators.http import require_POST from shop.models import Product from .cart import Cart from .forms import CartAddProductForm @require_POST def cart_add(request, product_id): cart = Cart(request) product = get_object_or_404(Product, id=product_id) form = CartAddProductForm(request.POST) if form.is_valid(): cd = form.cleaned_data cart.add(product=product, quantity=cd['quantity'], override_quantity=cd['override']) return redirect('cart:cart_detail') @require_POST def cart_remove(request, product_id): cart = Cart(request) product = get_object_or_404(Product, id=product_id) cart.remove(product) return redirect('cart:cart_detail') def cart_detail(request): cart = Cart(request) for item in cart: item['update_quantity_form'] = CartAddProductForm(initial={'quantity': item['quantity'], 'override': True}) return render(request, 'cart/detail.html', {'cart': cart})` Does anyone know how to fix this error?I solved the problem. In the base.html file, I had spaces in the line:
Correct spelling without spaces. There must be no spaces after the word "cart:". Correct ruler:
<a href=" replies "cart: cart_detail"% inc">
Exactly, there should be no spaces in
cart:cart_detail
. The code should look like this: