Automatically strip CharFields

1
2
3
4
5
6
7
8
9
from django import forms

def stripclean(self, value):
	if isinstance(value, basestring):
		value = value.strip()
	return oldclean(self, value)

oldclean = forms.fields.CharField.clean
forms.fields.CharField.clean = stripclean

More like this

  1. RedirectedURLField by stringify 3 years, 3 months ago
  2. CleanCharField by DvD 5 years, 7 months ago
  3. RangeField and RangeWidget by marinho 4 years, 7 months ago
  4. FixedCharField and related by andresj 4 years, 6 months ago
  5. Automatic stripping textual form fields by nail.xx 4 years, 9 months ago

Comments

(Forgotten your password?)