D
D
Daria2020-03-23 14:22:21
Django
Daria, 2020-03-23 14:22:21

Why is QuerySet not iterable?

{{topSale}}//(<QuerySet [<Product: Киви>, <Product: Морковь>, <Product: Гранат>]>,)
            {% for i in topSale %}
                 {{i}}//<QuerySet [<Product: Киви>, <Product: Морковь>, <Product: Гранат>]>

In square brackets, a list that is already normally iterable.
view
topSale = Product.objects.order_by('-is_view')[0:3],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-03-23
@Sestokova

The comma creates a tuple

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question