开发者

django ORM : how to make an select query with OR between two fields

I am new to djang开发者_Go百科o and need some quick help.

How will the following sql statement be translated in django ORM?

SELECT * from table_name WHERE field1 = v1 OR field2 = v2

Thanks in advance!


Use Q-objects:

Model.objects.filter(Q(field1=v1) | Q(field2=v2))
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜