Hi list,

I'm developing a (yet another) shopping cart and I'm having a problem
when counting the items in the cart.

In my model I have an "Order" class which is the cart and a
"OrderItem" class which are the items in the cart. In the Order class
I have this code:

[PYTHON]
class Order(models.Model):
    def count_items(self):
        items = 0
        for item in self.orderitem_set.filter(order=self):
            items += item.quantity
        return items
    count = property(count_items)
[/PYTHON]

When I run the application I get the error:
[ERROR]
OperationalError at /
(1241, 'Operand should contain 1 column(s)')
Request Method:         GET
Request URL:    http://localhost:8000/
Exception Type:         OperationalError
Exception Value:        (1241, 'Operand should contain 1 column(s)')
Exception Location:
        /var/lib/python-support/python2.4/MySQLdb/connections.py in
defaulterrorhandler, line 35
Python Executable:      /usr/bin/python
Python Version:         2.4.4
[/ERROR]

Something strange is that the exception is thrown while rendering the template:
[ERROR]
Caught an exception while rendering: (1241, 'Operand should contain 1
column(s)')
73      <div class="cartdata">
74      {{ cart.count }} item{{ cart.count|pluralize }}
75      </div>
[/ERROR]

Any idea? Thanks in advance,

AlvAro

"You can't change the world, but you can change your mind."
Software Libre: El conocimiento no puede tener dueño.

--~--~---------~--~----~------------~-------~--~----~
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