Answer the question
In order to leave comments, you need to log in
How to filter ForeignKey Django?
In chat, I need to get the number of unread messages for the user and I can't seem to get it done with django orm, here's a sketch:
chat.message_set.exclude(readers__contains=user).count()
sum([1 for m in self.message_set.all() if user in m.readers.all()])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question