#24084: Alias related properties inside values()
----------------------------------------------+--------------------
     Reporter:  iambibhas                     |      Owner:  nobody
         Type:  New feature                   |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 Right now we can use values() to fetch properties like this -

 {{{
 >>> Entry.objects.values('blog')
 [{'blog': 1}, ...]
 }}}

 But I have a case where I need to fetch a property from a related mode so
 I'm doing this -

 {{{
 >>> Boundary.objects.values('id', 'school__liblangagg__class_name')
 [{'school__liblangagg__class_name': 6, 'id': 8999},
 {'school__liblangagg__class_name': 5, 'id': 8954},
 {'school__liblangagg__class_name': 3, 'id': 9000},
 {'school__liblangagg__class_name': 2, 'id': 8942},]
 }}}

 It'd be really convenient if I could alias the related property. Something
 like this -

 {{{
 >>> Boundary.objects.values('id', ('class_name',
 'school__liblangagg__class_name'))
 [{'class_name': 6, 'id': 8999}, ... ]
 }}}

 So in place of the string representing the related property, we could have
 a tuple (alias, related_string). The output looks a bit ugly to pass this
 on to somewhere and it's a bit of work to iterate over all of them and
 replace the key.

 Does it seem like a feature worth considering?

--
Ticket URL: <https://code.djangoproject.com/ticket/24084>
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/052.500304591c38c1d846d1532f87c7b8b7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to