Answer the question
In order to leave comments, you need to log in
How to filter model objects in Django ORM by the number of many-to-many objects of another model associated with them?
Hello.
I understand Django ORM and I have a question about filtering in many-to-many relationships.
For example, there are two models: books and authors.
class Author(models.Model):
name = models.CharField(max_length=100)
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ManyToManyField(Author)
author1.book_set.all()
Answer the question
In order to leave comments, you need to log in
An amazing thing is the documentation, so much can be found there if you search, isn't it true ;)?
https://docs.djangoproject.com/en/2.0/topics/db/ag...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question