#34868: Add K as an alias for KeyTransform.from_lookup
-------------------------------------+-------------------------------------
Reporter: Paolo | Owner: nobody
Melchiorre |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I propose to add K as an alias for KeyTransform.from_lookup
It's something possible to do in `django.contrib.postgres` before Django
3.1 and it can still be useful now to get non-textual data back from
database.
This would be an example of use and I show the difference with KT
{{{#!pycon
>>> qs = MyModel.objects.all()
>>> values = qs.values_list(
K("value__true"),
K("value__false"),
K("value__none"),
K("value__dict"),
K("value__list"),
)
[True, False, None, {"k": "v"}, [None, True, False]]
>>> text_values = qs.values_list(
KT("value__true"),
KT("value__false"),
KT("value__none"),
KT("value__dict"),
KT("value__list"),
)
["true", "false", "null", '{"k":"v"}', "[null,true,false]"]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34868>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018abe9c9d4b-1a0425fd-93a2-47e2-a7b0-31ae254d9e05-000000%40eu-central-1.amazonses.com.