I'm trying to print some query with values_list but for some reason it is still printing and I need to be gone and only have the list inside the square brackets...
def resum(request):
usuari=Usuari.objects.order_by('usuari_id').values_list('usuari_id', flat=True)
print(usuari)
and what i get printed is:
<QuerySet [1, 2, 3, 4, 5, 6, 50, 51]>
[06/Jun/2019 01:21:04] "GET /resum/ HTTP/1.1" 200 2102
Any idea??
Thanks!
Simply use the list()
function:
def resum(request):
usuari=Usuari.objects.order_by('usuari_id').values_list('usuari_id', flat=True)
print(list(usuari))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.