code: def get_related_model(field):
      
      model = None
  
      if hasattr(field, 'related_model') and field.related_model:   #  pragma: no cover
          model = field.related_model
      # Django<1.8 doesn't have the related_model API, so we need to use rel,
      # which was removed in Django 2.0
      elif hasattr(field, 'rel') and field.rel:  # pragma: no cover
          model = field.rel.to
  
      return model
docs: Gets the related model from a related field