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))
精彩评论