I have a table for Actor that I query and populate the result in
actor_list to pass to the template. I installed the Django Debug
Toolbar to check the queries hitting the database and found some
strange behavior. If I iterate through the actor_list, only one SQL
query is created, as expected:
{% for actor in actor_list %}
{{ actor.id }}
{% endfor %}
But if I call a particular item in the list before the loop, that
additional call generates its own query, meaning the database is hit
twice.
{{ actor_list.0.id }}
{% for actor in actor_list %}
{{ actor.id }}
{% endfor %}
Why is that? Is there a way to do this that doesn't result in two
queries?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.