I'm not sure where you are getting the "u" from. It should be user, such as:
AppointmentParticipant.objects.filter(participant_user__pk=user.id).select_related() You don't really need the depth in this case, unless you have more to your models I'm not seeing. The rest of it looks fine. Michael Trier blog.michaeltrier.com On Dec 15, 2007 12:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, > > Thanks for your answers which helped me a lot. > > Finally my models.py looks like: > > def appointments_all(request): > user = request.user > appointments = > AppointmentParticipant.objects.filter(participant_user__pk=u.id).select_related(depth=2) > return render_to_response('appointments_all.html', {"user" : > user, "appointments": appointments}, context_instance = > RequestContext(request)) > > > appointments_all generates a SQL statement with all the implicit joins > I need. > > So my appointments_all.html is similar to: > > ... > <h1>Appointments for {{ user.user_name }}</h1> > > <table id='UserAppointments'> > > {% for appointment in appointments %} > <tr> > <td>{{ appointment.appointment.description }}</td> > <td>{{ appointment.appointment.start_timestamp }}</td> > <td>{{ appointment.appointment.end_timestamp }}</td> > <td>{{ appointment.participant_role.description }}</td> > </tr> > {% endfor %} > > </table> > ... > > > Yours, > Michael > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---