0

When developing a website i run over a question. I have a query object and i want to iterate through all its` properties like

for i in object:
    print(i)

Haven`t found anything on Web. Any ideas?

Emelien
  • 55
  • 6
  • A query object contains a lot more properties other than the model fields. You can use the `.values` as stated here https://stackoverflow.com/questions/7811556/how-do-i-convert-a-django-queryset-into-list-of-dicts – Nayan Apr 11 '18 at 03:45
  • Ah, thanks a lot, Nayan! That's exactly what I've been looking for! – Emelien Apr 12 '18 at 05:49
  • I'm posting an answer. Hope you'll accept as it worked. – Nayan Apr 12 '18 at 06:42

1 Answers1

1

A query object contains a lot more properties other than the model fields. You can use the .values.

Here is how to use this: How do I convert a Django QuerySet into list of dicts?

Nayan
  • 1,521
  • 2
  • 13
  • 27