I will not map proper url in html page

when I hit this url

<a href="/cart/pk">Cart<span>{{request.session.cart|length}}</span></a>

I got error "The current path, cart/, didn't match any of these."

so please tell how map proper url

my url.py file:

path('cart/<int:pk>',views.cartitem,name='cart'),

My cartitem.py file:

def cartitem(request,pk):

cart=request.session.get('cart')
if cart is None:
    cart=[]

for c in cart:
    tshirt_id=c.get('tshirt')
    product_id=c.get('product')
    product = get_object_or_404(Product,pk=pk)
    tshirt=Tshirt.objects.get(pk=pk)

    c['size']= Sizevariant.objects.get(tshirt=tshirt_id, size=c['size'])
    c['tshirt']=tshirt
    c['product']=product

return render(request,"cart.html",{'cart':cart,'product':product,'tshirt':tshirt})


Read more here: https://stackoverflow.com/questions/66276868/i-will-not-map-proper-url-in-html-page

Content Attribution

This content was originally published by Finishers. venom gaming at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: