              number = min(number, self.high_mark - self.low_mark)
  
          return number
  
      def has_results(self, using):
          q = self.clone()
          if not q.distinct:
              q.clear_select_clause()
 
</s> remove         def _build_clear_filters(self, qs):
            filters = Q(**{
                self.source_field_name: self.related_val,
                '%s__in' % self.target_field_name: qs
            })

 </s> add         def _build_remove_filters(self, removed_vals):
            filters = Q(**{self.source_field_name: self.related_val})
            # No need to add a subquery condition if removed_vals is a QuerySet without
            # filters.
            removed_vals_filters = (not isinstance(removed_vals, QuerySet) or
                                    removed_vals._has_filters())
            if removed_vals_filters:
                filters &= Q(**{'%s__in' % self.target_field_name: removed_vals}) </s> remove 
            old_vals_qs = self.using(db).filter(**{
                '%s__in' % self.target_field.related_field.attname: old_ids})
            filters = self._build_clear_filters(old_vals_qs)
 </s> add             target_model_qs = super(ManyRelatedManager, self).get_queryset()
            if target_model_qs._has_filters():
                old_vals = target_model_qs.using(db).filter(**{
                    '%s__in' % self.target_field.related_field.attname: old_ids})
            else:
                old_vals = old_ids
            filters = self._build_remove_filters(old_vals) </s> remove                 filters |= Q(**{
                    self.target_field_name: self.related_val,
                    '%s__in' % self.source_field_name: qs
                })
 </s> add                 symmetrical_filters = Q(**{self.target_field_name: self.related_val})
                if removed_vals_filters:
                    symmetrical_filters &= Q(
                        **{'%s__in' % self.source_field_name: removed_vals})
                filters |= symmetrical_filters </s> remove             filters = self._build_clear_filters(self.using(db))
 </s> add             filters = self._build_remove_filters(super(ManyRelatedManager, self).get_queryset().using(db))
    def has_filters(self):
        return self.where or self.having

              number = min(number, self.high_mark - self.low_mark)
  
          return number
  
    def has_filters(self):
        return self.where or self.having

      def has_results(self, using):
          q = self.clone()
          if not q.distinct:
              q.clear_select_clause()
keep keep keep add keep keep keep keep
 Used simpler queries for m2m clearing when possible.

Refs #21169 
django/db/models/sql/query.py