What do you mean by the sum or average of the method? As in the sum or
average of the method applied to a list of objects "X"?

On Sun, Nov 23, 2014 at 7:41 PM, Jorge Andrés Vergara Ebratt <
javebr...@gmail.com> wrote:

> Hello everyone,
>
> Well, the tittle says it all:
>
> I have a model X
>
> class X(models.Model)
>     a = models.IntegerField()
>     b = models.IntegerField()
>
> def getC(self):
>     return a + b
>
>
> So, when I'm inside a template I can call {{x.getC}} and it gets the
> method for the current instance it's in, but how can I get the Sum, or Avg
> of that method? I tried doing Sum('getC') but I get the error because getC
> isn't callable in the query...
>
> Thanks in advance for the help
>
> --
> *Jorge Andres Vergara Ebratt*
> *#SoftwareDeveloper (Or at least trying to be)*
> *@javebratt*
> *facebook.com/javebratt <http://facebook.com/javebratt>*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAeX05Gb5oV%3DkiBcAeMdQ33jcau2B_yWYXFMgJbNB4Y8QMJ5Qw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAeX05Gb5oV%3DkiBcAeMdQ33jcau2B_yWYXFMgJbNB4Y8QMJ5Qw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2Rb3j8OZ9MEKsjnB8x8xwJ_z5nLuJKja-QZpZRgGu6SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to