def count_active_tables(self):
        return len([1 for count in self.alias_refcount.values() if count])
Returns the number of tables in this query with a non-zero reference
dataset/ETHPy150Open django/django/django/db/models/sql/query.py/Query.count_active_tables