开发者

Django - replacing string in Model.objects.extra for variable

开发者 https://www.devze.com 2023-03-20 20:00 出处:网络
For example, if I have list of ids values like this: values = list(set(Handler.objects.filter(blog=1).values_list(\'entry_id\', f开发者_运维技巧lat=True)))

For example, if I have list of ids values like this:

values = list(set(Handler.objects.filter(blog=1).values_list('entry_id', f开发者_运维技巧lat=True)))

and i want to give variable "values" instead of numbers in string format to extra method like this:

Entry.objects.extra(where=['id IN (3, 4, 5, 20)'])

It is possible somehow to replace numbers for "values"?


... Huh?

Entry.objects.filter(id__in=values)
0

精彩评论

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