Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django:Getting List of values from query set

I have the following query

country=employees.objects.filter(manager_id__emp_id=111).values('emp_loc').distinct()

I get Output as <QuerySet [{'emp_loc': 'IND'}, {'emp_loc': 'MLA'}]>

But I need list

['IND','MLA']

How Can I do it?

like image 971
divya Avatar asked Nov 09 '17 13:11

divya


1 Answers

Use values_list instead.

country=employees.objects.filter(manager_id__emp_id=111).values_list('emp_loc', flat=True).distinct()
like image 116
hspandher Avatar answered Oct 11 '22 13:10

hspandher