I've got a users table, a groups table, and a groups_users table, corresponding to User and Group classes with a RelatedJoin. It's of course quite easy to get all the users in a given group or all the groups of which a given user is a member. But now I'd like to find all the users which aren't in a group.

An SQL way would be
SELECT * FROM users WHERE id NOT IN (SELECT user_id FROM groups_users);

Is there an SQLObjectish way to do that query? Or should I just go like
noGroupUsers = [x for x in User.select() if x.groups == []]
? (Since I have only dozens of users, it doesn't matter if I fetch them all; but I'd like to know how to get the database to do the work if possible, for future reference.)