3

How to check if value is in manytomany field? I am trying to do something like this:

if value in object1.followers:
    #BLA BLA BLA

But 'ManyRelatedManager' is not iterable. So what is correct way to do it?

Irmantas Želionis
  • 2,194
  • 3
  • 17
  • 30

1 Answers1

10

You forgot the all():

if value in object1.followers.all():
    ...
Joren
  • 3,068
  • 25
  • 44