我想在psql中执行以下查询:
select a.*, b.name from tbl_broadcast_living as a inner join tbl_broadcast as b on a.broadcast_id=b.broadcast_id;
我的模特是:
class TblBroadcast(models.Model):
broadcast_id = models.AutoField(primary_key=True, db_column='broadcast_id')
name = models.CharField(max_length=255, db_column='name')
class Meta:
managed = False
db_table = 'tbl_broadcast'
app_label = 'operation'
def __unicode__(self):
return 'id %s' % self.broadcast_id
class TblBroadcastLiving(models.Model):
channel_id = models.IntegerField(primary_key=True)
broadcast_id = models.IntegerField()
class Meta:
managed = False
db_table = 'tbl_broadcast_living'
app_label = 'operation'
def __unicode__(self):
return 'id %s' % self.channel_id
最重要的是我想在tbl_broadcast表中使用tbl_broadcast_living所有列获取名称〜 如何使用django queryset执行此操作?感谢。