#21314 closed New feature (duplicate)

Feature request: allow renaming of fields in dicts returned by ValuesQuerySet via kwargs

Reported by: chris@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be convenient to be able to rename the fields returned by ValuesQuerySet by passing keyword arguments to QuerySet.values(), e.g.

>>> Foo.objects.all().values('id', 'bar__name')
[{'id': 1, 'bar__name': 'Bar'}]

>>> Foo.objects.all().values('id', bar__name='name')
[{'id': 1, 'name': 'Bar'}]

I think using extra(select=...) and values() can achieve this but with significant verbosity.

Change History (1)

comment:1 Changed 22 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #16735

Note: See TracTickets for help on using tickets.
Back to Top