On Mon, 2008-11-10 at 14:52 -0800, chris wrote:
> Now, to answer myself, I found the solution:
>
> qs =
> Reference.objects.all().extra(select={'title_count'
> :'COUNT(*)'}).values('title',
> 'title_count')
> qs.query.group_by = ['title']
>
> This gives me exactly the aggregated list of titles
Now, to answer myself, I found the solution:
qs =
Reference.objects.all().extra(select={'title_count'
:'COUNT(*)'}).values('title',
'title_count')
qs.query.group_by = ['title']
This gives me exactly the aggregated list of titles with the number of
occurrences. The trick with group_by is undocu
Thanks Malcolm,
This brings me one step closer, but not quite there.
On Nov 10, 8:21 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> > SELECT title, COUNT (*) AS count FROM persons_reference GROUP BY title
> > ORDER BY count DESC
>
> > Trying to get the same from the Django ORM, I do the fol
On Sun, 2008-11-09 at 22:19 -0800, chris wrote:
> Dear Django users,
>
> Here is the problem I am trying to solve:
>
> I have a Reference object defined as follows:
>
> class Reference(models.Model):
> person = models.ForeignKey(Person)
> author = models.CharField(max_length = 20, bla
Dear Django users,
Here is the problem I am trying to solve:
I have a Reference object defined as follows:
class Reference(models.Model):
person = models.ForeignKey(Person)
author = models.CharField(max_length = 20, blank=True)
location = models.CharField(max_length=255, blank=Tru
5 matches
Mail list logo