Reputation: 2702
Basicly I just want to say "give me all the values from column Y" and not "select all values and filter for Y based on primary key Z"
The word "column" is only mentioned one time on the Django documentation page and the "primary key" and "row" options are very clearly explained in my eyes.
Now I wonder, how do I do this? :)
Upvotes: 5
Views: 7242
Reputation: 10256
If I understand well, you want to query values for only a column, I think this is what you need:
MyModel.objects.values('column_name')
Or if you want to get a list of values:
MyModel.objects.values_list('column_name', flat=True)
You can apply any filter before selecting values:
MyModel.objects.filter(**criteria**).values_list('column_name', flat=True)
Upvotes: 20