1 | Index: newforms/fields.py
|
---|
2 | ===================================================================
|
---|
3 | --- newforms/fields.py (revision 5753)
|
---|
4 | +++ newforms/fields.py (working copy)
|
---|
5 | @@ -101,12 +101,14 @@
|
---|
6 | return {}
|
---|
7 |
|
---|
8 | class CharField(Field):
|
---|
9 | - def __init__(self, max_length=None, min_length=None, *args, **kwargs):
|
---|
10 | - self.max_length, self.min_length = max_length, min_length
|
---|
11 | + def __init__(self, max_length=None, min_length=None, strip=False, *args, **kwargs):
|
---|
12 | + self.max_length, self.min_length, self.strip = max_length, min_length, strip
|
---|
13 | super(CharField, self).__init__(*args, **kwargs)
|
---|
14 |
|
---|
15 | def clean(self, value):
|
---|
16 | "Validates max_length and min_length. Returns a Unicode object."
|
---|
17 | + if self.strip:
|
---|
18 | + value = value.strip()
|
---|
19 | super(CharField, self).clean(value)
|
---|
20 | if value in EMPTY_VALUES:
|
---|
21 | return u''
|
---|