tags:

views:

81

answers:

2

If I have following database fields: id, name, emp_id.

How do I make a query in Django to get the values of column name only with a where clause.

Thanks...

+7  A: 
Model.objects.filter(...).values('name')
Ignacio Vazquez-Abrams
Thanks......................
Hulk
+5  A: 

In addition to the answer provided by Ignacio Vazquez-Abrams, you could also use values_list to get the names in a flat list (instead of a dictionary).

Model.objects.filter(...).values_list('name', flat=True)

See the documentation for values_list.

Brian Neal
Thanks......................
Hulk