Asked • 07/12/19

How to perform OR condition in django queryset?

I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income is NULL. How to construct the Django queryset filter? User.objects.filter(income__gte=5000, income=0) This doesn't work, because it `AND`s the filters. I want to `OR` the filters to get union of individual querysets.

1 Expert Answer

By:

Stephen F. answered • 10/15/19

Tutor
New to Wyzant

Experienced Tutor in R, Statistics, Programming, and Social Sciences

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.