2
我正在寻找使用Inner Join的特定原始SQL查询。Django - 对与PostgreSQL的多对多关系进行SQL查询内部加入
我有那些机型:
class EzMap(models.Model):
layers = models.ManyToManyField(Shapefile, verbose_name='Layers to display', null=True, blank=True)
class Shapefile(models.Model):
filename = models.CharField(max_length=255)
class Feature(models.Model):
shapefile = models.ForeignKey(Shapefile)
我想作一个SQL查询有效PostgreSQL的,将是这样一个:
select id from "table_feature" where' shapefile_ezmap_id = 1 ;
但我不知道如何使用INNER JOIN
以过滤features
其中shapefile
它们所属的与特定的ezmap
对象
非常感谢。然后使用QuerySet.query,我可以得到我需要的原始SQL查询 –