Re: order by count of related object

2009-06-30 Thread graeme
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

Re: order by count of related object

2009-06-17 Thread R C
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

Re: order by count of related object

2009-06-17 Thread Alex Gaynor
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

Re: order by count of related object

2009-06-17 Thread R C
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

Re: order by count of related object

2009-06-17 Thread Daniel Roseman
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

order by count of related object

2009-06-17 Thread R C
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()

Re: order by count

2009-01-29 Thread lollerikken
; >> 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

Re: order by count

2009-01-29 Thread Brandon Taylor
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

order by count

2009-01-29 Thread lollerikken
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. --~--~-~--~~~---~--~--

django-tagging "tags_for_model" order by count

2008-09-10 Thread jhill10110
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

Re: Order by count

2008-07-25 Thread mtrythall
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