
Stephen F. answered 10/15/19
Experienced Tutor in R, Statistics, Programming, and Social Sciences
The `django.db.models` package provides a `Q` object that you can use to compose more filtering statements. Instead of using with `.filter()`, you use it with `.get()`, combining multiple OR clauses with a vertical pipe `|`. For example:
This would roughly translate into:
You can combine multiple comma-separated `Q` objects to `.get()`, which will act like parenthesized `AND` clauses.
which would be like
If you combine `Q` clauses with keyword arguments, just make sure that the `Q` argument comes first:
For more information, check out the Django documentation page: https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q-objects