Hello,

from django.contrib.auth.models import User

class Team(models.Model):
   users = models.ManyToManyField(User)


I would like to retrieve every User in my database who does not belong
to a team.
I'm facing to this problem for several hours, and I found a *very*
crappy solution :

 def _get_all_users_in_teams():
     for team in Team.objects.all():
         for user in team.users.all():
             yield user.pk

 CHOICES = User.objects.all().exclude(pk__in=[id for id in
_get_all_users_in_teams()])

Is there something better?
I'm on django 1.2.4

Regards,
-- 
J.

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

Reply via email to