Yes, instead of returning all the records and counting them in python
you would be using your databases COUNT() funciton.
On Mar 27, 10:33 pm, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> On Mar 27, 3:43 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Well, books can be redefined as
On Mar 27, 3:43 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Well, books can be redefined as:
>
> def books(self):
> progs = self.programs.all()
> return sum([prog.publications.all().filter(type=u'Book').count()
> for prog in progs])
>
> and likewise for the other methods.
Nice.
Well, books can be redefined as:
def books(self):
progs = self.programs.all()
return sum([prog.publications.all().filter(type=u'Book').count()
for prog in progs])
and likewise for the other methods.
On Mar 27, 1:27 pm, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> My application has t
My application has the following models: Researcher, Program and
Publication.
Each Researcher has 0 or more Programs as a ManyToManyField, and each
Program has 0 or more Publications also as a ManyToManyField.
Publication has a 'type' attribute which is a CharField, and has
choices: Book, Article
4 matches
Mail list logo