def make_trimming(field):
    def clean_hook(self, old_clean, value):
        result = old_clean(value)
        if isinstance(result, (str, unicode,)):
            result = result.strip()
        return result
    old_clean = field.clean
    import new
    field.clean = new.instancemethod(
        lambda self, value: clean_hook(self, old_clean, value),
        field, field.__class__)