📜  原始查询必须包含主键 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:26.551000             🧑  作者: Mango

代码示例1
queryset=country_model.objects.raw('SELECT myapp_country_model.cname,myapp_state_model.sname FROM myapp_country_model INNER JOIN myapp_state_model on myapp_country_model.id=myapp_state_model.cid_id')
Solution
queryset=country_model.objects.raw('SELECT myapp_country_model.id,myapp_country_model.cname,myapp_state_model.sname FROM myapp_country_model INNER JOIN myapp_state_model on myapp_country_model.id=myapp_state_model.cid_id ')