code: def invalidate_m2m_cache(sender, instance, model, **kwargs):
      
      logger.debug('Received m2m_changed signals from sender {0}'.format(sender))
      update_model_cache(instance._meta.db_table)
      update_model_cache(model._meta.db_table)
docs: Signal receiver for models to invalidate model cache for many-to-many relationship.
  
      Parameters
      ~~~~~~~~~~
      sender
          The model class
      instance
          The instance whose many-to-many relation is updated.
      model
          The class of the objects that are added to, removed from or cleared from the relation.