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?
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?
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