#27535: RFE: Exclude pk from queries
-------------------------------------+-------------------------------------
     Reporter:  Alexander Todorov    |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  1.10
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Alexander Todorov):

 To answer the question from Tim. I want to be able to do the following:

 {{{
 Book.objects.values('genre').annotate(Avg('rating'))

 SELECT "demoproject_book"."genre_id", AVG("demoproject_book"."rating") AS
 "rating__avg" FROM "demoproject_book" GROUP BY
 "demoproject_book"."genre_id"
 }}}

 However iterate over objects not dict. I'm the new maintainer of django-
 chartit, where the user passes query sets as the source for charts and
 lists of terms for the X and Y axes. The terms are usually field names.
 Recently users have requested to be able to pass model attributes as terms
 and be able to use RawQuerySet as the chart source. Internally it is
 easier to work only with objects instead of special casing the value query
 set and work with dictionaries.

 I will the helper method proposed above as well. Thanks for the tip.

--
Ticket URL: <https://code.djangoproject.com/ticket/27535#comment:4>
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/066.f5270f94f62c9990ed1a0b031393fcea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to