Answer the question
In order to leave comments, you need to log in
Filtering objects in Django array?
there is a model
class Blog:
name = некоторое поле
class Entry:
blog = models.ForeignKey(Blog)
is_published = models.BooleanField()
blogs = Blog.objects.all()
Blog.objects.filter(entries__is_published=True) фильтрует сами блоги, а не записи в них
Answer the question
In order to leave comments, you need to log in
according to the documentation , you need to use entries__set
besides, it's not at all clear why you are trying to filter is_published=True
when you yourself write that you need unpublished...
class Blog:
name = некоторое поле
def non_published_entries(self):
return Entry.objects.filter(blog=self, is_published=False)
for blog in Blog.objects.all():
print(blog.non_published_entries())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question