(cls, field, val)
return val
Cut val to the maximum length of cls's field
Cut val to the maximum length of cls's field
Cut val to the maximum length of cls s field
def to_maxlength(cls, field, val):
    """Cut val to the maximum length of cls's field"""
    if val is None:
        return None

    max_length = cls._meta.get_field(field).max_length
    orig_length = len(val)
    if orig_length > max_length:
        val = val[:max_length]
        logger.warning(
            "%s.%s length reduced from %d to %d",
            cls.__name__,
            field,
            orig_length,
            max_length,
        )

    return val
def to_maxlength ( cls , field , val ) : if val is None : return None max_length = cls . _meta . get_field ( field ) . max_length orig_length = len ( val ) if orig_length > max_length : val = val [ : max_length ] logger . warning ( "%s.%s length reduced from %d to %d" , cls . __name__ , field , orig_length , max_length , ) return val