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?
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?
Use values_list instead.
country=employees.objects.filter(manager_id__emp_id=111).values_list('emp_loc', flat=True).distinct()
As an alternative suggestion:
country = [ list(elem) for elem in list(employees.objects.filter(manager_id__emp_id=111).values_list('emp_loc', flat=True).distinct()]