Opened 12 years ago

Last modified 12 years ago

#19512 closed New feature

Aggregate or Annotaion on previously Annotated values — at Initial Version

Reported by: eye-see-you@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: django, annotate, aggregate
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.db.models import Count, Sum, F

myModel.objects \

.annotate(a_count=Count('field_a'), b_count=Count('field_b')) \
.annotate(total=F('a_count')+F('b_count')) \
.order_by('total')

This query is going to raise AttributeError: 'ExpressionNode' object has no attribute 'split'

I don't find any method in django ORM to support such kind of operations (in which two fields are involved).

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top