36👍
Use QuerySet.values_list
and specify flat=True
:
firstnames = Users.objects.values_list('firstnames', flat=True)
firstnames = list(firstnames)
1👍
def get_array(Table, column):
rows = Table.objects.values(column)
return [row[column] for row in rows]
print get_array(Users, 'firstnames')
- [Django]-Django – how to process/clean a field before validation
- [Django]-Exception Value:failed to find libmagic. Check your installation in windows 7
- [Django]-How do I create a slug in Django?
Source:stackexchange.com