Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed FormWrapper.fields (from [1253]) to be a property, so that it…

…'s only called when needed.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1257 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a469d821a12fc337d534cb9d499942296c1bd126 1 parent 2d49f70
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 django/core/formfields.py
View
10 django/core/formfields.py
@@ -108,7 +108,6 @@ class FormWrapper:
def __init__(self, manipulator, data, error_dict):
self.manipulator, self.data = manipulator, data
self.error_dict = error_dict
- self.fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields]
def __repr__(self):
return repr(self.data)
@@ -128,6 +127,15 @@ def __getitem__(self, key):
def has_errors(self):
return self.error_dict != {}
+ def _get_fields(self):
+ try:
+ return self._fields
+ except AttributeError:
+ self._fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields]
+ return self._fields
+
+ fields = property(_get_fields)
+
class FormFieldWrapper:
"A bridge between the template system and an individual form field. Used by FormWrapper."
def __init__(self, formfield, data, error_list):
Please sign in to comment.
Something went wrong with that request. Please try again.