开发者

Django: raw SQL and values_list() bug?

开发者 https://www.devze.com 2023-01-31 15:58 出处:网络
Doing something lik开发者_StackOverflow中文版e SomeModel.objects.extra(..).values_list(\'id\', flat=True)

Doing something lik开发者_StackOverflow中文版e

SomeModel.objects.extra(..).values_list('id', flat=True)

always returns an empty list

Is this a Django bug ? Or am I missing seomthing?


From the documentation:

If you use a values() clause after an extra() clause, any fields defined by a select argument in the extra() must be explicitly included in the values() clause. However, if the extra() clause is used after the values(), the fields added by the select will be included automatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消