TypeError

10 views
Skip to first unread message

Soumen Khatua

unread,
May 22, 2019, 6:09:43 AM5/22/19
to django...@googlegroups.com
Hi Folks,

I'm getting this error "TypeError:" everytime, Can You guys tell me where is the problem in this code.

Cart

views.py
@require_POST
def cart_add(request,product_id):
cart = Cart(request)
product = get_object_or_404(Product,id  = product_id)
form = forms.CartAddProductForm(request.POST)
if form.is_valid():
cd  = form.cleaned_data
cart.add(
       product = product,
       quantity = cd['quantity'],
       update_quantity = cd['update'])
return redirect('cart:cart_detail')


def cart_detail(request):
cart = Cart(request)
return render (request,'cart/cartdetail.html',{'cart':cart})



cartdetail.html:
{% for item in cart %}
{{ item.quantity }}
{% endfor %}

Bob Gailer

unread,
May 22, 2019, 6:35:03 AM5/22/19
to Django users

On May 22, 2019 6:09 AM, "Soumen Khatua" <soumenk...@gmail.com> wrote:
>
> Hi Folks,
>
> I'm getting this error "TypeError:" everytime, Can You guys tell me where is the problem in this code.

it would help us a lot if you would copy the entire traceback and paste it into an email reply.

> Cart
>
> views.py
> @require_POST
> def cart_add(request,product_id):
> cart = Cart(request)
> product = get_object_or_404(Product,id  = product_id)
> form = forms.CartAddProductForm(request.POST)
> if form.is_valid():
> cd  = form.cleaned_data
> cart.add(
>        product = product,
>        quantity = cd['quantity'],
>        update_quantity = cd['update'])
> return redirect('cart:cart_detail')
>
>
> def cart_detail(request):
> cart = Cart(request)
> return render (request,'cart/cartdetail.html',{'cart':cart})
>
>
>
> cartdetail.html:
> {% for item in cart %}
> {{ item.quantity }}
> {% endfor %}
>

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYVTQWq-5WtiMo6HekSmaw6%2BRCxfRu4wbFF9BgYaDsPqg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages