On Mon, Mar 23, 2009 at 4:02 PM, eli <eliasz.wont...@gmail.com> wrote:

>
> anybody?
>
> On 23 Mar, 16:17, eli <eliasz.wont...@gmail.com> wrote:
> > How to pass to the Sum() function (ORM) more than one field?
> >
> > My problem:
> >
> > class Model1(models.Model):
> >     name = models.CharField(u'Name', max_length=255)
> >
> > class Model2(models.Model):
> >     fk1 = models.ForeignKey(Model1, related_name='fk_1')
> >     fk2 = models.ForeignKey(Model1, related_name='fk_2')
> >
> > I want to sort data by sum of fk1 and fk2 field.
> >
> > Model1.objects.annotate(myfk1=Count('fk1', distinct=True), myfk2=Count
> > ('fk2', distinct=True)).annotate(my_sum=Sum('myfk1+myfk2')).order_by('-
> > my_sum')
> >
> > Thanks for help.
> >
> > regards.
> >
>
You've waited only 4 hours, and many people haven't had chance to see this
sinec they're either at work or on the other side of the world(asleep).
Please be patient.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to