I want to fetch an object, sometimes with one condition and some other time adding (OR) another condition.
With Laravel (PHP), this is easy to do:
$q = MyModel::where('col1', $val1);
if ($userWantsToAddAnotherOrCondition) {
$q = $q->orWhere('col2', $val2);
}
At the end I have a query either with condition 'col1' = $va1 or 'col1' = $va1 OR 'col2' = $val2.
In Django (python), I only know this way:
q = MyModel.objects.filter(Q(col1=val1) | Q(col2=val2))
How can I add the second condition (col2=val2) with another statement ?