I can’t quite pinpoint where the problem is, could be syntax or there is something about the querysets returned by django I don’t quite get.
Class1(models.Model):
...
def __add__(self,other)
return other + ({'attribute': value}, ..)
I’m hoping that the addition between classes will return 1 tuple with all the objects and put into it.
Because of that, I’ve had to avoid the sum() function since it’s looking for integers.
Class Summate():
@staticmethod
def sum_tuples(items)
return reduce(lambda y,x: x+y, items)
eg_list = Class1.objects.all()
values = Summate.sum_tuples(eg_list)
I get back an TypeError: reduce() of empty sequence with no initial value.
UPDATE: My lists were empty. I resolved that and received this error
TypeError: unsupported operand type(s) for +: ‘dict’ and ‘dict’
But shouldn’t it be appending the tuple and not the dicts?
Any thoughts? Am I going about this completely wrong?
Thanks,
Your filter must simply be returning no results. I just tested your code and it works.