Opened 5 years ago

Closed 2 years ago

#12222 closed New feature (duplicate)

rename items in values()

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

Description (last modified by lukeplant)

I wish there were a way to do instead of this:

MyModel.objects.values('otherfield__anotherjoinedfield__blah__derp__foo__doop')
{'otherfield__anotherjoinedfield__blah__derp__foo__doop': 4, 'otherfield__anotherjoinedfield__blah__derp__foo__doop': 5, [...]

you could do this:

MyModel.objects.values(val='otherfield__anotherjoinedfield__blah__derp__foo__doop')
{'val': 4, 'val': 5, [...]

Change History (8)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed
  1. Please use preview.
  2. I think you're looking for !__in.

comment:2 Changed 5 years ago by anonymous

Sorry I didn't realize it would change the formatting. I'd fix it if I could but I can't figure out how to edit it.

"__in" has nothing to do with what the ticket was about. You know how you can rename an annotation by doing .annotate(name=Sum('field'))? Well that functionality should exist for values() as well.

comment:3 Changed 5 years ago by kmtracey

  • Description modified (diff)

comment:4 Changed 5 years ago by lukeplant

  • Description modified (diff)

comment:5 Changed 3 years ago by simonotron

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

For what it's worth, I also think this would be useful...

comment:6 Changed 3 years ago by lukeplant

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature

I think Russell misread the ticket, probably due to lack of formatting. It sounds like a reasonable idea, and API seems OK.

comment:7 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:8 Changed 2 years ago by bmispelon

  • Resolution set to duplicate
  • Status changed from new to closed

This is a duplicate of #16735.

I'm closing this one because the other one seems to have more activity.

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