@classmethod
    def _is_simple_query(cls, query):
        useable = (
            not query.low_mark and
            not query.high_mark and
            not query.select and
            not query.group_by and
            not query.distinct and
            not query.order_by and
            len(query.tables) <= 1
        )

        if hasattr(query, 'having'):  # Django < 1.9
            useable = (useable and not query.having)

        return useable
Inspect the internals of the Query and say if we think its WHERE clause
dataset/ETHPy150Open adamchainz/django-mysql/django_mysql/models/handler.py/Handler._is_simple_query