[Answered ]-How to queryset all user that are in a foreign table?


Try this:


I’m assuming there is only one foreign key from the Book model to the User model.

  • isnull filters for all users which are in the which are linked to the Book model.
  • distinct ensures that each author only appears once in the results.

Leave a comment