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 django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to