'Pickle and b64encode the object, optionally compressing it.
The pickling protocol is specified explicitly (by default 2),
rather than as -1 or HIGHEST_PROTOCOL, because we don\'t want the
protocol to change over time. If it did, ``exact`` and ``in``
lookups would likely fail, since pickle would now be generating
a different string.'

def get_db_prep_value(self, value, connection=None, prepared=False):

    if ((value is not None) and (not isinstance(value, PickledObject))):
        value = force_text(dbsafe_encode(value, self.compress, self.protocol))
    return value
