Combining Disparate QuerySets in Django

While refactoring strongarm.io we ran into a problem: we had different database tables that we needed to query over as if they were a single database table. We use Django as an ORM and needed to stay within the ORM in order to leverage third-party libraries.

Our two models have overlapping fields, in this instance both had a name field to search over and a created field to order on. A naive implementation might serialize all the data to memory and come up with implementations like:

Currently Django QuerySetSequence supports both Django 1.8 and Django 1.9 on Python 2.7, 3.4 and 3.5. Check out the full set of features or contribute to the source repository. You can install django-querysetsequence package frompypi using pip: