Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
レコードを 2 つのカテゴリにグループ化したいと思います。
どうすればいいですか?annotate() の使用を検討しています。
q = Book.objects.annotate(num_authors=Count('authors')) books_with_3_or_over_authors = q.filter(num_authors__gte=3) books_with_less_than_3_authors = q.filter(num_authors__lt=3)