1 2 3 4 5 6 7 8 9 10 11 | 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__)
|
More like this
- DefaultValueWidget by miracle2k 5 years, 10 months ago
- filter/search a newforms select widget by miracle2k 5 years, 8 months ago
- Load templatetag libraries via settings by miracle2k 5 years, 9 months ago
- "Approved" field with timestamp by miracle2k 5 years, 10 months ago
- SeparatedValuesField by jezdez 5 years, 5 months ago
Comments