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 4 years, 6 months ago
- Getting dynamic model choices in newforms by ubernostrum 4 years, 11 months ago
- assign fields dynamically in newforms by rubic 4 years, 11 months ago
- Hidden Forms by insin 4 years, 7 months ago
- Form rendering using a template instead of builtin HTML by leoh 4 years, 8 months ago
Comments