code: def validate_character_for_story_element(sender, instance, action, reverse, pk_set, *args, **kwargs):
      '''
      Validates that character is from the same outline as the story node.
      '''
      if action == 'pre_add':
          if reverse:
              for spk in pk_set:
                  story_node = StoryElementNode.objects.get(pk=spk)
                  if instance.outline != story_node.outline:
                      raise IntegrityError(_('Character Instance must be from the same outline as story node.'))
          else:
              for cpk in pk_set:
                  char_instance = CharacterInstance.objects.get(pk=cpk)
                  if char_instance.outline != instance.outline:
                      raise IntegrityError(_('Character Instance must be from the same outline as story node.')f validate_character_for_story_element(sender, instance, action, reverse, pk_set, *args, **kwargs):
      '''
      Validates that character is from the same outline as the story node.
      '''
      if action == 'pre_add':
          if reverse:
              for spk in pk_set:
                  story_node = StoryElementNode.objects.get(pk=spk)
                  if instance.outline != story_node.outline:
                      raise IntegrityError(_('Character Instance must be from the same outline as story node.'))
          else:
              for cpk in pk_set:
                  char_instance = CharacterInstance.objects.get(pk=cpk)
                  if char_instance.outline != instance.outline:
                      raise IntegrityError(_('Character Instance must be from the same outline as story node.'))
docs: Validates that character is from the same outline as the story node.