I have a perfectly legal query into my database.  When I add
'order_by' some field, it gives the results just fine.  But when I add
distinct() to it, it dies:

>>> res.order_by('blk__name')
[<B# 171: eudswmy qv eyslqw>, <B# 171: eudswmy qv eyslqw edskbp nvdpi
ldoyzb>, <B# 171: eudswmy qv>, <B# 84: hqmnlbt rle atocv>, <B# 84:
hqmnlbt rle atocv>]
>>> res.order_by('block__name').distinct()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/db/models/query.py",
line 143, in __repr__
    return repr(list(self))
  File "/usr/lib/python2.4/site-packages/django/db/models/query.py",
line 155, in __len__
    self._result_cache.extend(list(self._iter))
  File "/usr/lib/python2.4/site-packages/django/db/models/query.py",
line 273, in iterator
    obj = self.model(*row[index_start:])
  File "/usr/lib/python2.4/site-packages/django/db/models/base.py",
line 181, in __init__
    raise IndexError("Number of args exceeds number of fields")
IndexError: Number of args exceeds number of fields

Is this a known bug?  Or am I doing something wrong?  Note that I am
tracking the development version.

Strangely, if I order_by a different field (one that is not a
ForeignKey), then the problem goes away.

Thanks,
Brian


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to