请帮帮我!如何转换此 SELECT hotel_id FROM hotelrooms GROUP BY hotel_id HAVING COUNT(room_id) < 20
去django orm?
型号:
class hotelrooms(models.Model):
room_id = models.IntegerField()
hotel_id = models.IntegerField()
price = models.IntegerField()
请帮帮我!如何转换此 SELECT hotel_id FROM hotelrooms GROUP BY hotel_id HAVING COUNT(room_id) < 20
去django orm?
型号:
class hotelrooms(models.Model):
room_id = models.IntegerField()
hotel_id = models.IntegerField()
price = models.IntegerField()
1条答案
按热度按时间6ie5vjzr1#
您可以通过以下方式进行查询:
也就是说,看起来这些应该是**
ForeignKey
**s[django文件]。ForeignKey
引用另一个模型,因此可以强制引用完整性。