i would like convert a django queryset into an array like,
firstnames=Users.objects.values(\'firstnames\')
to get a result that looks like
def get_array(Table, column): rows = Table.objects.values(column) return [row[column] for row in rows] print get_array(Users, 'firstnames')
Use QuerySet.values_list and specify flat=True:
flat=True
firstnames = Users.objects.values_list('firstnames', flat=True) firstnames = list(firstnames)