How can you check the type of a many-to-many-field in django?
I wanted to do it this way:
import django
field.__class__ == django.db.models.fields.related.ManyRelatedManager
This doesn't work, because the class ManyRelatedManager can't be found.
But if i do field.__class__ the output is django.db.models.fields.related.ManyRelatedManager
Why does it refer to a class that doesn't seem to exist and how can i bring it to work?
Many thanks for your help.
If you already have the field instance you can simply do:
If you only have the related manager instance, you can reverse lookup the field instance:
This has only been tested on Django 1.5