"del( some_dict[id] )", if you have a dict.  but it looks here like you 
have a list containing a dict...

i highly recommend buying a python book....i liked the "Python Essential 
Reference" by David M. Beazley when i was first learning python (still 
am, actually), if you're already comfortable with programming in 
general.  (if not, something else - it's not an intro-to-oop book)

http://www.amazon.com/Python-Essential-Reference-Developers-Library/dp/0672328623/ref=sr_1_1/105-2347441-5534819?ie=UTF8&s=books&qid=1184942097&sr=8-1



Greg wrote:
> 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': c})
> 
> What method do I use on request.session to delete only one "row" in my
> cart dictionary?  Does cart have an id field that I can access?
> 
> Thanks
> 
> On Jul 20, 8:44 am, Greg <[EMAIL PROTECTED]> wrote:
>> 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/
>>>> 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 Price, so it holds
>>> a Price object.
>>>> class Price(models.Model):
>>>>    name = models.IntegerField()
>>>>    def __str__(self,):
>>>>            return str(self.name)
>>>>    class Admin:
>>>>            pass
>>>> class Choice(models.Model):
>>>>     choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
>>>> num_in_admin=5)
>>>>     size = models.ForeignKey(Size, core=True)
>>>>     price = models.ForeignKey(Price, core=True)
>>>>     def __str__(self,):
>>>>    return str((self.size, self.price))
>>> The only integer defined is Price.name. Does this work:
>>>  pr = pr + a['choice'].price.name
>>> ?
>>> I would suggest that you change the name of that field ... "name" does
>>> not really convey that this is the value of the price - it sounds more
>>> like a label for it (like "SuperSaver").
>>> Perhaps you could get rid of the Price class altogether? If it just
>>> holds an integer, you could use an IntegerField directly in Choice ...
>>> Nis
> 
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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