Django equivalent for SQL query using INNER JOIN -clause

前端 未结 1 693
忘了有多久
忘了有多久 2021-01-25 20:30

I would like to know the django equivalent for the SQL-query that uses the INNER JOIN -clause. I have two models that are linked with ForeignKey.

class Item(mode         


        
1条回答
  •  野的像风
    2021-01-25 21:30

    You can use filter and only to get desired result.

    Try:

    Request.objects.filter(item__item_is_locked=False).only('item_owner', 'message_body')
    

    0 讨论(0)
提交回复
热议问题