开发者

How to filter a django queryset using an array on a field like SQL's "IN"?

开发者 https://www.devze.com 2023-01-21 03:03 出处:网络
I\'d like to filter a Django queryset using an array as a constraint on a field.AKA, my array, for example, a set of primary keys.I want to get only the objects that would be in开发者_开发百科 that ar

I'd like to filter a Django queryset using an array as a constraint on a field. AKA, my array, for example, a set of primary keys. I want to get only the objects that would be in开发者_开发百科 that array, like the query in SQL would be:

SELECT * from table where id in [1,3,4,5,6....];


.filter(id__in=[1, 3, 4, 5, 6....])

Read more about it at Django docs.

0

精彩评论

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

关注公众号