Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于 Django 中的自定义查询,我几乎没有什么要求
Person.objects.raw('SELECT id, first_name, last_name, birth_date FROM Person A inner join Address B on A.address = B.id ')
or B.id = A.address_id
您需要在原始查询中使用数据库的表和字段名称——您提供的字符串将被传递给数据库,而不是由 Django ORM 解释。