[Answered ]-How to get Class Model name from ManyToManyField in Django

2👍

groups = models.ManyToManyField(Group)

def generated_sql(self):
    print [(f.name, f.related.parent_model) for f in self._meta.many_to_many]

iPython ftw

Leave a comment