Hi,

I am starting a simple web app that can be introduced as a collection
of Agendas (represented as Django models).
Each Agenda is composed of Appointments (at least one), and each
Appointment records 0 or more Invitees.
Basically, I would like to display the content of this Agenda on a
page, i.e list all its Appointments, and display the list of Invitees
for each Appointment.

The simplest solution I found is to retrieve my Agenda in my view, and
then rely on the template to display the subsequent elements, e.g:
{{ agenda.details }}
{% for appointment in agenda.appointment_set.all %}
  {{ appointment.details }}
  {% for invitee in appointment.invitee_set.all %}
    {{ invitee.details}}
  {% endfor %}
{% endfor %}

However, doing so, the number of queries executed increases due to the
inner loop of retrieving all invitees for each appointment of this
agenda.

Is there a better solution in terms of performance (i.e less queries
on the database), to retrieve this cascaded information? I thought
about the 'select_related' statement on my queryset, but it covers non-
null foreign keys only.

Thanks in advance for any hint.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to