This appears to be a new feature.
Is there any way of doing this in 1.0? Other than dropping into SQL
that is.
Graeme
On Jun 17, 8:04 pm, Alex Gaynor wrote:
> On Wed, Jun 17, 2009 at 10:00 AM, R C wrote:
>
> > Thanks for your fast reply
>
> > I realize that there is no "count" field in m
Thanks, it worked!
Both of you have been very helpful.
On Jun 17, 5:04 pm, Alex Gaynor wrote:
> On Wed, Jun 17, 2009 at 10:00 AM, R C wrote:
>
> > Thanks for your fast reply
>
> > I realize that there is no "count" field in my article model. However
> > in my templates I am able to do thi
On Wed, Jun 17, 2009 at 10:00 AM, R C wrote:
>
> Thanks for your fast reply
>
> I realize that there is no "count" field in my article model. However
> in my templates I am able to do things like:
> Author.article_set.count
>
> I just can't do the same thing in my views when building a
> que
Thanks for your fast reply
I realize that there is no "count" field in my article model. However
in my templates I am able to do things like:
Author.article_set.count
I just can't do the same thing in my views when building a
queryset.I would really like to be able to select Authors and
On Jun 17, 1:12 pm, R C wrote:
> Hi,
>
> I would like to be able to select objects and order them by the count
> of a related field
>
> For example, I have 2 models:
>
> class Author(models.Model)
> name = models.Charfield(max_length=20)
>
> class Article(models.Model)
> author = models.F
Hi,
I would like to be able to select objects and order them by the count
of a related field
For example, I have 2 models:
class Author(models.Model)
name = models.Charfield(max_length=20)
class Article(models.Model)
author = models.ForeignKey(Author)
content = models.TextField()
;
>> My google search suggested that I should use something called annotate
>> combined with count, but it does not work.
>> I have tried something like:
>> table.objects.values('key',
>> 'ref').annotate(nr_ref=Count('ref')).order_by('nr_ref
g called annotate
> combined with count, but it does not work.
> I have tried something like:
> table.objects.values('key',
> 'ref').annotate(nr_ref=Count('ref')).order_by('nr_ref')
> but without any luck.
> --
> View
nnotate(nr_ref=Count('ref')).order_by('nr_ref')
but without any luck.
--
View this message in context:
http://www.nabble.com/order-by-count-tp21732508p21732508.html
Sent from the django-users mailing list archive at Nabble.com.
--~--~-~--~~~---~--~--
I'm really new to both python and django so please be gentle with
me :-)
I would like to order the results of "tags_for_model" in django-
tagging by tag count rather than tag name which is set in the Meta
class of the Tag model.
What is the best approach for this? Should I do this in the templat
Thanks Dan. I was trying to avoid doing a custom query, but groupby
would work.
On Jul 24, 3:27 pm, Dan Lazewatsky <[EMAIL PROTECTED]> wrote:
> I'm not sure if there's anything built into Django to do this, but you
> should be able to accomplish it with a custom query and some crafty use
> of gro
11 matches
Mail list logo