Opened 14 months ago
Closed 14 months ago
#34868 closed Cleanup/optimization (wontfix)
Add K as an alias for KeyTransform.from_lookup
Reported by: | Paolo Melchiorre | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | json key type |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
>>> 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]"]
Change History (2)
comment:1 by , 14 months ago
Keywords: | json key type added |
---|---|
Needs documentation: | set |
comment:2 by , 14 months ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
As far as I'm aware exposing a new API is unnecessary,
F()
should work just fine.