#28940: Annotate SUM aggregation value as field
-------------------------------------+-------------------------------------
               Reporter:  marriva    |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Hello

 How can I do this in Django without .extra() method?

 SELECT SUM(column_1) AS total, column_1, column_2 FROM table


 In your documentation you said that I should create the ticket if I use
 .extra() method, so I'm here


 Model.objects.extra(select={'total': 'select sum(field) from model'})

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28940>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.6821ddb911a362251c15090a1eb4fa0f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to