How to get the array consisting of arrays containing the fields from the table row in Django QuerySet API? -


how array consisting of arrays containing fields table row in django queryset api?

db table example:

id | col1 | col2 | col3

1 | 12 | 123 | 11

2 | 2 | 23 | 2

3 ....

...

expected result:

arr = [ [12,123,11], [2,23,2], ... ]

found solution:

id = entry.objects.values_list('id', flat=true).order_by('id')

[1, 2, 3, ...]

col1 = entry.objects.values_list('col1', flat=true).order_by('id')

[ 12 ,123 ,11 ]

col2 = entry.objects.values_list('col2', flat=true).order_by('id')

[ 2 , 23, 2]

arr = zip(col1, col2)

why don't do

entry.objects.values_list() 

that's does.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -