Bound fields are now cached on the model instance.

ImageSpecFile and AdminThumbnailView are created on the first access, and
then assigned as properties of the model instance for subsequent access.
This commit is contained in:
Eric Eldredge 2011-09-25 12:42:27 -04:00
parent f570bd0d7f
commit c00ea10b0a

View file

@ -263,8 +263,10 @@ class _ImageSpecDescriptor(object):
if instance is None:
return self.field
else:
return ImageSpecFile(instance, self.field, self.attname,
self._get_image_field_file(instance))
img_spec_file = ImageSpecFile(instance, self.field,
self.attname, self._get_image_field_file(instance))
setattr(instance, self.attname, img_spec_file)
return img_spec_file
def _post_save_handler(sender, instance=None, created=False, raw=False, **kwargs):