How can I find the union of two Django querysets?

This works and looks a bit cleaner:

records = query1 | query2

If you don’t want duplicates, then you will need to append .distinct():

records = (query1 | query2).distinct()

Leave a Comment