Emelien
Emelien

Reputation: 55

Is there a way to iterate through a single django query object?

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?

Upvotes: 0

Views: 659

Answers (1)

Nayan
Nayan

Reputation: 1605

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?

Upvotes: 1

Related Questions