您好我有三個型號,如何使用加入在Django ORM
class Subscriber(models.Model):
subscriberId = models.SmallIntegerField(null= True,unique=True)
def __unicode__(self):
return str(self.subscriberId)
class Text(models.Model):
subscriberId = models.ForeignKey(Subscriber, null=False)
content = models.CharField(max_length=162 ,blank= True)
def __unicode__(self):
return str(self.subscriberId)
class Text2(models.Model):
subscriberId = models.ForeignKey(Subscriber, null=False)
Du = models.IntegerField()
def __unicode__(self):
return str(self.subscriberId))
我得從文本和文本2數據對一個特定的用戶。 MySQL中我使用
select * from Server_Text JOIN (Server_Text2) ON (Server_Text.subscriberId_id = 11 and Server_Text2.subscriberId_id = 11) ;
其中,服務器是我的數據庫的名字,這是工作的罰款。
我該如何在Django中使用它。
你有任何查詢,你已經嘗試過嗎? –