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...
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...
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
.