2
您好我正在Django中制作后端服务器,用于存储来自应用程序的用户数据。 以下是我的模特儿。如何使用Django加入
class Subscriber(models.Model):
subId = models.IntegerField(max_length=20,unique=True,blank=False)
Name = models.CharField(max_length=25,blank=True)
class SMS(models.Model):
subscriberId = models.ForeignKey(Subscriber, null=False)
epochTime = models.IntegerField(null = False)
time = models.CharField(max_length= 250 ,blank = False)
class Call(models.Model):
subscriberId = models.ForeignKey(Subscriber, null=True)
epochTime = models.IntegerField(null = False)
time = models.CharField(max_length= 50 ,blank = False)
Date = models.CharField(max_length= 50 ,blank = False)
我需要写一个Django查询,我会给subscriberId和Django会回到我使用的数据来自呼叫和SMS(基本上要用加入)该用户。 早些时候我已经在mysql中应用了这个。
select * from Server_Text JOIN (Server_Call) ON (Server_SMS.subscriberId_id = 11 and Server_Call.subscriberId_id = 11) ;
其中Server是我的mysql数据库。
https://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward 这是你已经看过的东西吗? – Kendas
是的,但我没有得到解决这个问题的完美解决方案。 :-( –