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|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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'
Change History (6)
comment:1 Changed 7 years ago by Simon G. <dev@…>
- Triage Stage changed from Unreviewed to Design decision needed
comment:5 Changed 7 years ago by mtredinnick
- Triage Stage changed from Design decision needed to Accepted