[Answered ]-Building a Django Q object for query

1👍

You pass it as named parameter, so:

Q(accounts_payable_line_item__property__pk__in=properties) | Q(
    journal_line_item__property__pk__in=properties
)

or as 2-tuples with a string and value:

Q(('accounts_payable_line_item__property__pk__in', properties)) | Q(
    ('journal_line_item__property__pk__in', properties)
)

you can also define the _connector and thus construct this through one Q call:

Q(
    accounts_payable_line_item__property__pk__in=properties,
    journal_line_item__property__pk__in=properties,
    _connector=Q.OR,
)

Leave a comment