@contextlib.contextmanager
    def delay_mptt_updates(self):
        with self.disable_mptt_updates():
            if self.model._mptt_is_tracking:
                # already tracking, noop.
                yield
            else:
                self.model._mptt_start_tracking()
                try:
                    yield
                except Exception:
                    # stop tracking, but discard results
                    self.model._mptt_stop_tracking()
                    raise
                results = self.model._mptt_stop_tracking()
                partial_rebuild = self.partial_rebuild
                for tree_id in results:
                    partial_rebuild(tree_id)
Context manager. Delays mptt updates until the end of a block of bulk
dataset/ETHPy150Open django-mptt/django-mptt/mptt/managers.py/TreeManager.delay_mptt_updates