Reputation: 6540
For example if i want print indexes of this objects:
items = Item.objects.filter(depth=1)
How can i do this?
Upvotes: 0
Views: 132
Reputation: 866
If you want to print the positional index of a list/iterator of items (like a queryset), you can do something like the following:
for i, obj in enumerate(items):
print i, obj
The value of i will be the index of the given model instance.
Upvotes: 1