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?
如果model_obj
是Model类的实例,该实例定义了一个名为foom2m
的ManyToManyField,则可以执行以下操作:
related_model = model_obj.__class_.foom2m.field.rel.to
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.