Query when parameter is none django

Viewed 11506

I want to make a query, something like

Model.objects.filter(x=x).filter(y=y).filter(z=z) 

... but there are some cases when for example y is None. This literally searches the database for null values in the y column -- is there a nifty way to essentially disregard that query parameter if it is none, i.e. return the queryset

Model.objects.filter(x=x).filter(z=z)?
5 Answers
Related