def _truncate_to_field(model, field_name, value):
 field = model._meta.get_field(field_name)
 if (len(value) > field.max_length):
  midpoint = (field.max_length // 2)
  len_after_midpoint = (field.max_length - midpoint)
  first = value[:midpoint]
  sep = u'...'
  last = value[((len(value) - len_after_midpoint) + len(sep)):]
  value = sep.join([first, last])
 return value

def _truncate_to_field ( model , field_name , value ) : field = model . _meta . get_field ( field_name ) if ( len ( value ) > field . max_length ) : midpoint = ( field . max_length // 2 ) len_after_midpoint = ( field . max_length - midpoint ) first = value [ : midpoint ] sep = u'...' last = value [ ( ( len ( value ) - len_after_midpoint ) + len ( sep ) ) : ] value = sep . join ( [ first , last ] ) return value
if data is too big for the field .