diafygi
unread,Aug 4, 2011, 3:19:37 PM8/4/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Howdy all,
I'm know you can create a list of dictionaries for a queryset using
values(). However, I'm wondering if you can create one dictionary
where the keys are the primary keys of the result.
For example:
class Car(models.Model):
vin = models.IntegerField()
>>Model.objects.all().values()
[{'id' : 1, 'vin' : 189554}, {'id' : 1, 'vin' : 189555}, ...]
Is there a built in way to get:
>>Model.objects.all().something_pk_values()
{1 : {'vin':189554}, 2 : {'vin':189555}}
Thanks!
Daniel