On Wed, Jun 3, 2009 at 5:22 PM, Don Spaulding <[email protected]>wrote:
> > > > On Jun 3, 3:05 pm, Alex Gaynor <[email protected]> wrote: > > On Wed, Jun 3, 2009 at 3:03 PM, Don Spaulding <[email protected] > >wrote: > > > > > > > > > > > > > bump. > > > > > Can anyone tell me if this looks like a bug in Django? > > > > > On Jun 1, 6:12 pm, Don Spaulding <[email protected]> wrote: > > > > Hi all, > > > > > > I've got a quick use case that I think should work according to the > > > > docs, but it's not. In this case, Domain objects have a reverse fkey > > > > relation named "reports", and the Report model has an "updated" > > > > field. I'd like to annotate and order Domains by the max value of > > > > "updated" for all related reports. The following interactive session > > > > shows the behavior pretty well. > > > > > > >>> qs = > > > > Domain.objects.annotate(last_updated=Max('reports__updated')).order_by('last_updated') > > > > >>> qs.count() > > > > 1577 > > > > >>> print qs[0].last_updated > > > > > > IndexError: list index out of range>>> qs.count() > > > > > > InternalError: current transaction is aborted, commands ignored until > > > > end of transaction block > > > > > > >>> connection._rollback() > > > > > > If I drop off the order_by call, things appear to work again. > > > > > > >>> qs = > Domain.objects.annotate(last_updated=Max('reports__updated')) > > > > >>> qs.count() > > > > 1577 > > > > >>> print qs[0].last_updated > > > > > > 2009-05-28 13:25:55.027600 > > > > > > What am I missing here (besides a thorough understanding of > > > > aggregation)? > > > > It looks like a bug in django at first glance. Out of curiosity what > > version of Django is it, since it looks a tiny bit like an old bug with > > queryset chaining, but I think that was fixed even before the first beta. > > > >>> django.get_version() > u'1.1 beta 1 SVN-10916' > > > > Ok, based on what you pasted it's almost certainly a bug in Django. Please file a bug, and if you can try to write up a testcase within the Django test framework, but if not try to provide a minimal set of Models and code to reproduce the bug. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

