Re: [M-R] order by on custom SELECT column

2006-05-02 Thread Adrian Holovaty
On 5/1/06, Cheng Zhang <[EMAIL PROTECTED]> wrote: > I use a custom SELECT column as: > select = { > 'choices': 'SELECT COUNT(*) FROM polls_choice WHERE > poll_id=polls_poll.id', > } > p = Poll.objects.extra(select=select).order_by('choices') > > By trying this, I found out a bug in the ORM layer

[M-R] order by on custom SELECT column

2006-05-01 Thread Cheng Zhang
On the models of tutorial 1, I want to get a list of Poll, order by how many choices it has. class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll)