Hey.

I have a model Course and then I have django.contrib.auth.models.User.
Users and courses are related through M2M, so a user can register for
many courses and a course can register multiple users. Now, given a
potentially very long list of users, I want to retrieve all the
courses for which all of those users have registered. Currently I have
implemented it in this manner:

courses = Course.objects.all()
for user in users:
  courses = courses.filter(users=user)
courses = courses.distinct()

As you might expect, I get the "maximum 32 tables in a join" error
when having a very long list of users. How would I go about doing what
I want here?

Deniz

--~--~---------~--~----~------------~-------~--~----~
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