【发布时间】:2015-08-10 04:05:27
【问题描述】:
我尝试在 django 中进行原始查询但出错
原始查询必须包含主键
这是查询:
posts= User.objects.raw('select auth_group.name, auth_user.username
from auth_user, auth_group, auth_user_groups
where auth_user.id = auth_user_groups.user_id AND auth_group.id = auth_user_groups.group_id')
你能帮帮我吗?
【问题讨论】:
-
请看这里以编写原始 sql 查询:docs.djangoproject.com/en/1.8/topics/db/sql
-
感谢我尝试使用原始 sql 但显示错误,就像我在上面编辑的那样。怎么样?
标签: python django django-models