code: def open_target_group_for_form(self, form):
          
          target = self.first_container_with_errors(form.errors.keys())
          if target is None:
              target = self.fields[0]
              if not getattr(target, '_active_originally_included', None):
                  target.active = True
              return target
  
          target.active = True
          return target
docs: Makes sure that the first group that should be open is open.
          This is either the first group with errors or the first group
          in the container, unless that first group was originally set to
          active=False.