Code

Opened 7 years ago

Closed 6 years ago

#4358 closed (fixed)

Inconsistent results between .values() and .values('field') when field is an fkey

Reported by: Collin Grady <cgrady@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: qs-rf-fixed
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In a model with a ForeignKey, (say Choice from the poll example), Choice.objects.values() will show one field as 'poll_id' for the ForeignKey.

However, if you want to select only that value, Choice.objects.values('poll_id') will raise FieldDoesNotExist. Instead it requires you to do Choice.objects.values('poll') and returns the values in the key 'poll'

Attachments (0)

Change History (6)

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by mtredinnick

  • Keywords qs-rf added

comment:3 Changed 7 years ago by mtredinnick

(In [6516]) queryset-refactor: Made the use of values() for ForeignKey fields consistent
and documented this feature. Refs #4358.

comment:4 Changed 7 years ago by mtredinnick

  • Keywords qs-rf-fixed added; qs-rf removed

comment:5 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Design decision needed to Accepted

comment:6 Changed 6 years ago by mtredinnick

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

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.