From dd49269c7db008b2567f50cb03c4d3d9b321daa1 Mon Sep 17 00:00:00 2001
From: Arthur Koziel
Date: Mon, 13 Sep 2010 00:04:27 +0000
Subject: [soc2010/app-loading] merged trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
---
django/forms/forms.py | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
(limited to 'django/forms/forms.py')
diff --git a/django/forms/forms.py b/django/forms/forms.py
index b3718efa9a..7b2bc66fc7 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -18,10 +18,10 @@ __all__ = ('BaseForm', 'Form')
NON_FIELD_ERRORS = '__all__'
def pretty_name(name):
- """Converts 'first_name' to 'First name'"""
- if not name:
- return u''
- return name.replace('_', ' ').capitalize()
+ """Converts 'first_name' to 'First name'"""
+ if not name:
+ return u''
+ return name.replace('_', ' ').capitalize()
def get_declared_fields(bases, attrs, with_base_fields=True):
"""
@@ -35,7 +35,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True):
Also integrates any additional media definitions
"""
fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)]
- fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter))
+ fields.sort(key=lambda x: x[1].creation_counter)
# If this class is subclassing another Form, add that Form's fields.
# Note that we loop over the bases in *reverse*. This is necessary in
@@ -213,7 +213,7 @@ class BaseForm(StrAndUnicode):
normal_row = u'%(label)s | %(errors)s%(field)s%(help_text)s |
',
error_row = u'%s |
',
row_ender = u'',
- help_text_html = u'
%s',
+ help_text_html = u'
%s',
errors_on_separate_row = False)
def as_ul(self):
@@ -222,7 +222,7 @@ class BaseForm(StrAndUnicode):
normal_row = u'%(errors)s%(label)s %(field)s%(help_text)s',
error_row = u'%s',
row_ender = '',
- help_text_html = u' %s',
+ help_text_html = u' %s',
errors_on_separate_row = False)
def as_p(self):
@@ -231,7 +231,7 @@ class BaseForm(StrAndUnicode):
normal_row = u'%(label)s %(field)s%(help_text)s
',
error_row = u'%s',
row_ender = '
',
- help_text_html = u' %s',
+ help_text_html = u' %s',
errors_on_separate_row = True)
def non_field_errors(self):
@@ -423,6 +423,7 @@ class BoundField(StrAndUnicode):
"""
if not widget:
widget = self.field.widget
+
attrs = attrs or {}
auto_id = self.auto_id
if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
@@ -430,6 +431,7 @@ class BoundField(StrAndUnicode):
attrs['id'] = auto_id
else:
attrs['id'] = self.html_initial_id
+
if not self.form.is_bound:
data = self.form.initial.get(self.name, self.field.initial)
if callable(data):
@@ -439,6 +441,8 @@ class BoundField(StrAndUnicode):
data = self.form.initial.get(self.name, self.field.initial)
else:
data = self.data
+ data = self.field.prepare_value(data)
+
if not only_initial:
name = self.html_name
else:
--
cgit v1.2.1