Django django.test django.db.models.fields.related_descriptors.ManyRelatedManager
<p>Please assert type: 'django.db.models.fields.related_descriptors.ManyRelatedManager'. </p>

<p>In other words, how to import the module in order to assert that the field 'user.groups' is of type 'django.db.models.fields.related_descriptors.ManyRelatedManager'?</p>

<pre><code>from django.db.models.fields import related_descriptors

# AttributeError: 'module' object has no attribute 'ManyRelatedManager'
self.assertIsInstance(user.groups, related_descriptors.ManyRelatedManager)

print(type(dummy_user.groups)) # &lt;class 'django.db.models.fields.related_descriptors.ManyRelatedManager'&gt;
</code></pre>

<p>Here's the error:
AttributeError: 'module' object has no attribute 'ManyRelatedManager</p>

<p>Thanks</p>

<p>You cannot make such an assertion on <code>user.groups</code> and <code>related_descriptors.ManyRelatedManager</code>. </p>

<p>The <code>ManyRelatedManager</code> class is not accessible using import like <code>from django.db.models.fields import related_descriptors</code> because if you look at the source code of django, the <code>ManyRelatedManager</code> lives inside of <code>create_forward_many_to_many_manager</code> function.</p>

<p>P.S. I do not see any reasons why you want to check the type of <code>user.groups</code>. It is always the same and tested by django tests already.</p>

python django