              self.assertEqual([f.attname for f in fields], expected_result)
  
      def test_local_fields(self):
          def is_data_field(f):
              return isinstance(f, Field) and not isinstance(f, related.ManyToManyField)
  
          for model, expected_result in TEST_RESULTS['local_fields'].items():
              fields = model._meta.local_fields
              self.assertEqual([f.attname for f in fields], expected_result)
              for f in fields:
 
</s> remove         if isinstance(f, ManyToManyField):
 </s> add         if f.many_to_many: </s> remove     # avoid a circular import
    from django.db.models.fields.related import ManyToManyField
 </s> add  </s> remove         # ForeignKey or ManyToManyFields
        if isinstance(db_field, (models.ForeignKey, models.ManyToManyField)):
 </s> add         # Foreign key or many-to-many fields
        if db_field.many_to_many or isinstance(db_field, models.ForeignKey): </s> remove             if isinstance(f, models.ManyToManyField):
 </s> add             if f.many_to_many: </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
            return isinstance(f, Field) and not f.many_to_many
              self.assertEqual([f.attname for f in fields], expected_result)
  
      def test_local_fields(self):
          def is_data_field(f):
            return isinstance(f, Field) and not f.many_to_many
  
          for model, expected_result in TEST_RESULTS['local_fields'].items():
              fields = model._meta.local_fields
              self.assertEqual([f.attname for f in fields], expected_result)
              for f in fields:
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/model_meta/tests.py