(cls, action, instance, **kwargs)
this method is called from a django signal (m2m_changed)
        see config.apps.ConfigConfig.connect_signals

        NOTE: post_clear is ignored because it is used by the
        sortedm2m package to reorder templates
        (m2m relationships are first cleared and then added back),
        there fore we need to ignore it to avoid emitting signals twice
this method is called from a django signal (m2m_changed)
        see config.apps.ConfigConfig.connect_signals
this method is called from a django signal ( m2m_changed ) see config . apps . ConfigConfig . connect_signals
def templates_changed(cls, action, instance, **kwargs):
        """
        this method is called from a django signal (m2m_changed)
        see config.apps.ConfigConfig.connect_signals

        NOTE: post_clear is ignored because it is used by the
        sortedm2m package to reorder templates
        (m2m relationships are first cleared and then added back),
        there fore we need to ignore it to avoid emitting signals twice
        """
        if action not in ['post_add', 'post_remove']:
            return
        # use atomic to ensure any code bound to
        # be executed via transaction.on_commit
        # is executed after the whole block
        with transaction.atomic():
            # do not send config modified signal if
            # config instance has just been created
            if not instance._just_created:
                # sends only config modified signal
                instance._send_config_modified_signal(action='m2m_templates_changed')
            if instance.status != 'modified':
                # sends both status modified and config modified signals
                instance.set_status_modified(send_config_modified_signal=False)
def templates_changed ( cls , action , instance , * * kwargs ) : if action not in [ 'post_add' , 'post_remove' ] : return # use atomic to ensure any code bound to # be executed via transaction.on_commit # is executed after the whole block with transaction . atomic ( ) : # do not send config modified signal if # config instance has just been created if not instance . _just_created : # sends only config modified signal instance . _send_config_modified_signal ( action = 'm2m_templates_changed' ) if instance . status != 'modified' : # sends both status modified and config modified signals instance . set_status_modified ( send_config_modified_signal = False )