嗨,我有以下课程
Class Test1(models.Model):
user = models.OneToOneField(User)
myotherid = models.CharField(max_length=255)
Class TestData(models.Model):
data = models.ForeignKey(Data)
test1 = models.ForeignKey(Test1)
Class Data(models.Model):
title = models.CharField(max_length=255)
我对 Django 模型和所有这一切都很陌生,我怎样才能获得 myotherid=1234 和 Data.title= "foo" 的所有 Test1 项目
本质上,执行此 SQL:
select Test1.* from Test1 t, TestData td, Data d where t.myotherid=1234 and t.id = td.test1 and td.data = d.id and d.title = "foo"
谢谢你的帮助