'Take a field and a value intended to be saved on that field, and
return placeholder SQL and accompanying params. Check for raw values,
expressions, and fields with get_placeholder() defined in that order.
When field is None, consider the value raw and use it as the
placeholder, with no corresponding parameters returned.'

def field_as_sql(self, field, val):

    if (field is None):
        (sql, params) = (val, [])
    elif hasattr(val, 'as_sql'):
        (sql, params) = self.compile(val)
    elif hasattr(field, 'get_placeholder'):
        (sql, params) = (field.get_placeholder(val, self, self.connection), [val])
    else:
        (sql, params) = ('%s', [val])
    params = self.connection.ops.modify_insert_params(sql, params)
    return (sql, params)
