外键上的注释返回外键.如何从查询中获取对象本身?在以下示例中,'the_user'是"投票"模型中的外键:
Vote.objects.values('the_user').annotate(vote_count=Count('the_user')).order_by('-vote_count')
Run Code Online (Sandbox Code Playgroud)
它会回来
[{'the_user': 4, 'vote_count': 12} , {'the_user': 6, 'vote_count': 2}]
Run Code Online (Sandbox Code Playgroud)
但我需要用户自己的对象..不是ids
| 归档时间: |
|
| 查看次数: |
1247 次 |
| 最近记录: |