I think what you're trying to do can be accomplished with the
queryset's .extra() method.
something like
Level.objects.all().extra(select={'unlocked':'count(**matching rows in
the join table**) > 0'})-Andre On Dec 30, 7:04 am, Deniz Dogan <[email protected]> wrote: > Hi > > I have a user profile which has a many-to-many relationship to a model > Level. The relationship is called "unlocked" and says which levels a > specific user has unlocked. Now I wish to retrieve all the levels but > "joined" with the user's unlocked levels, so that I get a QuerySet > containing exactly Level.objects.all() but with an extra column called > "unlocked" which is True if the user has unlocked that level and False > otherwise. > > Is there any way to accomplish this without using explicit SQL? > > Any help appreciated, > 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 -~----------~----~----~----~------~----~------~--~---

