我有2个型号:
from django.db import models
class Model1(models.Model):
name = models.CharField(max_length=30)
class Model2(models.Model):
name = models.CharField(max_length=30)
mdl1 = models.ForeignKey(Model1)
我可以通过model2访问model1
m2 = Model2.get(...)
m2.mdl1 # one Model1
有没有办法执行vise-versa访问:
m1 = Model1.get(...)
m1. # get all Model2 that belong to m1