我有这个models.py
class Sitename(models.Model):
#id = models.AutoField(primary_key=True) ## to be removed
site = models.CharField() ## find values
class Equipment(models.Model):
#id = models.AutoField(primary_key=True) ## to be removed
serialno = models.CharField() ## known values
class RSL(models.Model): ##Radio Station License
#id = models.AutoField(primary_key=True) ## to be removed
sitename = models.ForeignKey(Sitename)
equipment = models.ManyToManyField(Equipment)
我只知道Equipment
serialno
,我无法找出正确的查询集?到目前为止,我知道如何查询外键。
sn = 'abc'
equip = Equipment.objects.get(serialno=sn)
rsl = RSL.objects.?????
sitename = Site.objects.get(pk=rsl.pk)