#10060: Multiple table annotation failure
---------------------------------+------------------------------------
Reporter: svsharma@… | Owner:
Type: Bug | Status: new
Component: ORM aggregation | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by anonymous):
* ui_ux: => 0
* easy: => 0
Comment:
Another victim. I have a model {{{Foo}}}. I also have models {{{Bar}}} and
{{{Baz}}}, which each have a foreign key pointing to {{{Foo}}} with
related_names {{{'bars'}}}, and {{{'bazs'}}}, respectively:
{{{
for foo in Foo.objects.all().annotate(bar_count=Count('bars'),
baz_count=Count('bazs')):
print foo.bar_count # Was correct
print foo.baz_count # Was completely wrong, but not by any apparent
pattern (ie, the numbers seemed to be almost random)
}}}
I'm unable to display the {{{baz_count}}} in my template now, unless I
want to introduce an N+1 problem (ie, {{{foo.bazs.count()}}} during each
iteration)
--
Ticket URL: <https://code.djangoproject.com/ticket/10060#comment:29>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.