              filter_horizontal = ('name',)
  
          self.assertIsInvalid(
              ValidationTestModelAdmin, ValidationTestModel,
              "The value of 'filter_horizontal[0]' must be a ManyToManyField.",
              'admin.E020')
  
      def test_valid_case(self):
          class ValidationTestModelAdmin(ModelAdmin):
              filter_horizontal = ("users",)
 
</s> remove             "The value of 'filter_vertical[0]' must be a ManyToManyField.",
 </s> add             "The value of 'filter_vertical[0]' must be a many-to-many field.", </s> remove             "The value of 'raw_id_fields[0]' must be a ForeignKey or ManyToManyField.",
 </s> add             "The value of 'raw_id_fields[0]' must be a foreign key or a many-to-many field.", </s> remove             "The value of 'list_display[0]' must not be a ManyToManyField.",
 </s> add             "The value of 'list_display[0]' must not be a many-to-many field.", </s> remove              "a DateTimeField, ForeignKey or ManyToManyField."),
 </s> add              "a DateTimeField, a foreign key, or a many-to-many field."), </s> remove         m2m = isinstance(field, related.ManyToManyField)
        return relation, model, direct, m2m
 </s> add         return relation, model, direct, bool(field.many_to_many)  # many_to_many can be None
            "The value of 'filter_horizontal[0]' must be a many-to-many field.",
              filter_horizontal = ('name',)
  
          self.assertIsInvalid(
              ValidationTestModelAdmin, ValidationTestModel,
            "The value of 'filter_horizontal[0]' must be a many-to-many field.",
              'admin.E020')
  
      def test_valid_case(self):
          class ValidationTestModelAdmin(ModelAdmin):
              filter_horizontal = ("users",)
keep keep keep keep replace keep keep keep keep keep
 Refs #24227 -- Replaced M2M isinstance checks by field.many_to_many

Thanks Markus Holtermann, Collin Anderson and Tim Graham for the reviews. 
tests/modeladmin/tests.py