Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored

Showing 1 changed file with 9 additions and 1 deletion. Show diff stats Hide diff stats

  1. 10  django/core/formfields.py
10  django/core/formfields.py
@@ -108,7 +108,6 @@ class FormWrapper:
108 108
     def __init__(self, manipulator, data, error_dict):
109 109
         self.manipulator, self.data = manipulator, data
110 110
         self.error_dict = error_dict
111  
-        self.fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields]
112 111
 
113 112
     def __repr__(self):
114 113
         return repr(self.data)
@@ -128,6 +127,15 @@ def __getitem__(self, key):
128 127
     def has_errors(self):
129 128
         return self.error_dict != {}
130 129
 
  130
+    def _get_fields(self):
  131
+        try:
  132
+            return self._fields
  133
+        except AttributeError:
  134
+            self._fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields]
  135
+            return self._fields
  136
+
  137
+    fields = property(_get_fields)
  138
+
131 139
 class FormFieldWrapper:
132 140
     "A bridge between the template system and an individual form field. Used by FormWrapper."
133 141
     def __init__(self, formfield, data, error_list):

0 notes on commit a469d82

Please sign in to comment.
Something went wrong with that request. Please try again.