0
一個訪問我有2種型號:一對多和許多人在Django
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)
我可以訪問MODEL1通過MODEL2
m2 = Model2.get(...)
m2.mdl1 # one Model1
有什麼辦法來執行反之亦然訪問:
m1 = Model1.get(...)
m1. # get all Model2 that belong to m1