Clean up the form's code a little bit, to make it more consistantly go through one code path. Patch from Travis Swicegood.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17381 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2012-01-19 22:05:47 +00:00
parent e8e4293a48
commit 477f4d8061
1 changed files with 3 additions and 3 deletions

View File

@ -98,8 +98,8 @@ class BaseForm(StrAndUnicode):
return self.as_table() return self.as_table()
def __iter__(self): def __iter__(self):
for name, field in self.fields.items(): for name in self.fields:
yield BoundField(self, field, name) yield self[name]
def __getitem__(self, name): def __getitem__(self, name):
"Returns a BoundField with the given name." "Returns a BoundField with the given name."
@ -145,7 +145,7 @@ class BaseForm(StrAndUnicode):
for name, field in self.fields.items(): for name, field in self.fields.items():
html_class_attr = '' html_class_attr = ''
bf = BoundField(self, field, name) bf = self[name]
bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable. bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable.
if bf.is_hidden: if bf.is_hidden:
if bf_errors: if bf_errors: