queryset values into list

Django values_list vs values

Article.objects.values_list('id', flat=True) # flat=True will remove 
the tuples and return the list   [1, 2, 3, 4, 5, 6]

Article.objects.values('id')
[{'id':1}, {'id':2}, {'id':3}, {'id':4}, {'id':5}, {'id':6}]
how to convert queryset into list of values
Nodes.objects.filter(id=data_id[x]['portal_node']
).values_list('sensors', flat=True)


Comments

Popular posts from this blog

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line

How To Convert Html File/URL/String Into Image Using Python

How to get Full URL or get absolute url In Django