开发者

How do I get the class of a ManyToMany field in django models?

I have some fields in a model that are ManyToMany, I wa开发者_StackOverflow中文版nt 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜