Django

Code

Ticket #4358 (closed: fixed)

Opened 1 year ago

Last modified 3 weeks ago

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

Reported by: Collin Grady <cgrady@the-magi.us> Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc:
Triage Stage: Accepted Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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

Change History

07/22/07 01:10:55 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Design decision needed.

09/13/07 16:42:00 changed by mtredinnick

  • keywords set to qs-rf.

10/14/07 21:54:31 changed by mtredinnick

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

10/14/07 21:55:28 changed by mtredinnick

  • keywords changed from qs-rf to qs-rf-fixed.

10/14/07 21:56:38 changed by mtredinnick

  • stage changed from Design decision needed to Accepted.

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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/Change #4358 (Inconsistent results between .values() and .values('field') when field is an fkey)




Change Properties
Action