Ok...on to a new problem. I'm able to add stuff to my session and
also delete the entire sesssion. However, I'm not sure how to delete
a particular entry into my session variable. This is how i add stuff
to my session
cart = request.session.get('cart', [])
cart.append({'style': s, 'choice':
Yep...that worked. Thanks for your help Nis and Derek. I'll try to
modify my model file with your suggestions
On Jul 20, 5:46 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Greg skrev:> Derek,
> > Ok...I made the change and I'm now getting the error:
>
> > TypeError at /rugs/cart/1/4/
> >
Greg skrev:
> Derek,
> Ok...I made the change and I'm now getting the error:
>
> TypeError at /rugs/cart/1/4/
> unsupported operand type(s) for +: 'int' and 'Price'
>
> Is 'a['choice'].price' not an Int? It says it is in my model file.
>
No it doesn't - "price" is defined as a ForeignKey to
well, you're dealing in $$$, so you prob. want floats...but where is
your FloatField? an attribute of your class Price? or can you cast
your Price class to a float?
pr = 0.0
for a in cart:
pr = pr + float(a['choice'].price)
do you understand how classes in
Derek,
Ok...I made the change and I'm now getting the error:
TypeError at /rugs/cart/1/4/
unsupported operand type(s) for +: 'int' and 'Price'
Is 'a['choice'].price' not an Int? It says it is in my model file.
Here is my view
def showcart(request,
you were supposed to substitute "value" with whatever column you have
defined. (you didn't post your model def)
Greg wrote:
> Derek,
> I tried that and now I get the following error:
>
> AttributeError at /rugs/cart/1/4/
> 'Choice' object has no attribute 'value'
>
> /
>
> Here
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)
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 =
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'] =
9 matches
Mail list logo