code: def format_value(obj, field_name):
      
      display_func = getattr(obj, 'get_%s_display' % field_name, None)
      if display_func:
          return display_func()
      value = getattr(obj, field_name)
  
      if isinstance(value, models.fields.files.FieldFile):
          if value:
              return mark_safe('<a href="%s">%s</a>' % (
                  value.url,
                  os.path.basename(value.name),
              ))
          else:
              return ''
  
      if isinstance(value, models.Model):
          return format_value_instance(value)
  
      if isinstance(value, models.Manager):
          return mark_safe(', '.join(
              [format_value_instance(instance) for instance in value.all()]
          ))
      if value is None:
          value = ""
      return value
docs: Simple value formatting.
  
      If value is model instance returns link to detail view if exists.