Reputation: 41665
id_list = Foo.objects.values_list('id', flat=True)
name_list = Foo.objects.values_list('name', flat=True)
Can I get the two list conveniently, efficiently?
Upvotes: 0
Views: 925
Reputation: 599540
If by efficiently you mean in a single query, then you can get both attributes in one call and use zip
to decompose them into separate lists:
values = Foo.objects.values_list('id', 'name')
id_list, name_list = zip(*values)
Upvotes: 1