                      new_field.remote_field.model = old_field.remote_field.model
              old_field_dec = self.deep_deconstruct(old_field)
              new_field_dec = self.deep_deconstruct(new_field)
              if old_field_dec != new_field_dec:
                  both_m2m = (
                      isinstance(old_field, models.ManyToManyField) and
                      isinstance(new_field, models.ManyToManyField)
                  )
                  neither_m2m = (
                      not isinstance(old_field, models.ManyToManyField) and
                      not isinstance(new_field, models.ManyToManyField)
                  )
                  if both_m2m or neither_m2m:
                      # Either both fields are m2m or neither is
                      preserve_default = True
                      if (old_field.null and not new_field.null and not new_field.has_default() and
                              not isinstance(new_field, models.ManyToManyField)):
 
</s> remove                             not isinstance(new_field, models.ManyToManyField)):
 </s> add                             not new_field.many_to_many): </s> remove         if (not field.null and not field.has_default() and
                not isinstance(field, models.ManyToManyField) and
 </s> add         if (not field.null and not field.has_default() and not field.many_to_many and </s> remove         if not isinstance(field, (models.ForeignKey, models.ManyToManyField)):
 </s> add         if not field.many_to_many and not isinstance(field, (models.ForeignKey)): </s> remove                     "CurrentSiteManager cannot use '%s.%s' as it is not a ForeignKey or ManyToManyField." % (
 </s> add                     "CurrentSiteManager cannot use '%s.%s' as it is not a foreign key or a many-to-many field." % ( </s> remove                 if (isinstance(field, models.ManyToManyField) and
                        not field.remote_field.through._meta.auto_created):
 </s> add                 if field.many_to_many and not field.remote_field.through._meta.auto_created:
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                      new_field.remote_field.model = old_field.remote_field.model
              old_field_dec = self.deep_deconstruct(old_field)
              new_field_dec = self.deep_deconstruct(new_field)
              if old_field_dec != new_field_dec:
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                both_m2m = old_field.many_to_many and new_field.many_to_many
                neither_m2m = not old_field.many_to_many and not new_field.many_to_many
                  if both_m2m or neither_m2m:
                      # Either both fields are m2m or neither is
                      preserve_default = True
                      if (old_field.null and not new_field.null and not new_field.has_default() and
                              not isinstance(new_field, models.ManyToManyField)):
keep keep keep keep replace replace replace replace replace replace replace 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. 
django/db/migrations/autodetector.py