Derek,
I tried that and now I get the following error:

AttributeError at /rugs/cart/1/4/
'Choice' object has no attribute 'value'

/////////////

Here is my view

def showcart(request, style_id, choice_id):
        s = Style.objects.get(id=style_id)
        c = Choice.objects.get(id=choice_id)
        #x = c.size, " ", c.price
        cart = request.session.get('cart', [])
        cart.append({'style': s, 'choice': c})
        request.session['cart'] = cart
        pr = 0
        for a in cart:
                pr = pr + a['choice'].value
        return render_to_response('show_test.html', {'mychoice': cart, 'p':
pr})

/////////





On Jul 19, 4:22 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
> you're not adding two ints, you're adding an int to an instance of your
> Choice class.  make your line:
>
>               pr = pr + a['choice'].value
>
> or whatever you called it.
>
> Greg wrote:
> > Hello,
> > I have the following view
>
> > def showcart(request, style_id, choice_id):
> >    s = Style.objects.get(id=style_id)
> >    c = Choice.objects.get(id=choice_id)
> >    cart = request.session.get('cart', [])
> >    cart.append({'style': s, 'choice': c})
> >    request.session['cart'] = cart
> >         pr = 0
> >    for a in cart:
> >             pr = pr + a['choice']
> >         return render_to_response('show_test.html', {'mychoice': cart,
> > 'p': pr})
>
> > /////////
>
> > Whenever i try this I get the error:
>
> > TypeError at /rugs/cart/1/4/
> > unsupported operand type(s) for +: 'int' and 'Choice'
>
> > //////////////////////////
>
> > Anybody know how I pull a value out of a dict and add it to a existing
> > number?
>
> > Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to