Feels hard to parse, might be clearer as:

        for model in _syncing_models[0:insert_idx]:
            if model in get_foreign_key_classes(model):
                raise Exception("Dependency loop detected in syncing models; cannot proceed.")