On 6 July 2011 08:17, Benedict Verheyen <benedict.verhe...@gmail.com> wrote:
> > I have these models (not really but it's to explain my question :)) > > class Calendar(models.Model): > name = models.CharField(max_length=60) > description = models.TextField(blank=True) > appointment = models.ManyToManyField(Appointment, > related_name='appointment_set') > > class Appointment(models.Model): > name = models.CharField(max_length=60) > description = models.TextField(blank=True) > owner = models.ForeignKey(User, related_name='owner_set') > > If I want to show the Calendars of the logged in user, I would have to > itterate the calendar objects, > getting the related appointments and from there the user. > I think this should work: Calendar.objects.filter(appointment__owner = request.user) Try it and see. Malcolm -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.