views:

9

answers:

1

Hi Django newbie here,

I have some fields in a model that are ManyToMany, I want the ManyToMany class itself, when I only have the field name. Is there any way I can retrieve it?

+1  A: 

If model_obj were an instance of the Model class that defines a ManyToManyField named foom2m, then you could do this:

related_model = model_obj.__class_.foom2m.field.rel.to
Joseph Spiros
Thanks, it worked! :)
apple_pie