class A(models.Model):
name = models.CharField(max_length=30, blank=True)
ida = models.CharFileld(max_length=30, blank=True)
class B(models.Model):
name = models.CharField(max_length=30, blank=True)
idb = models.CharField(max_length=30, blank=True)
a = models.ForeignKey(to="A", on_delete=models.CASCADE,related_name='a')
正查
a_id = B.objects.get(id=1).a
反查
b_id= A.objects.get(id=1).a.all().values()
idb= A.objects.filter(id=1).values('a__idb') 这里的 a ☞ related_name='a'
没有related_name属性时
b_id = A.objects.get(id=1).b_set.all().values() 采用类名小写_set的方式