Ticket #11084: 11084-proposed-fix.patch

File 11084-proposed-fix.patch, 1.1 KB (added by Armin Ronacher, 16 years ago)

untested proposal for a quick fix.

  • django/db/models/fields/files.py

    diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
    old mode 100644
    new mode 100755
    index 61a903e..44b0928
    a b class ImageFileDescriptor(FileDescriptor):  
    300300    assigning the width/height to the width_field/height_field, if appropriate.
    301301    """
    302302    def __set__(self, instance, value):
     303        update_dimensions = instance.__dict__.get(self.field.name) is None
    303304        super(ImageFileDescriptor, self).__set__(instance, value)
    304305       
    305306        # The rest of this method deals with width/height fields, so we can
    306         # bail early if neither is used.
    307         if not self.field.width_field and not self.field.height_field:
     307        # bail early if neither is used or we don't have to update the
     308        # dimensons because the data is coming from the database
     309        if not (update_dimensions and (self.field.width_field or
     310                                       self.field.height_field)):
    308311            return
    309312       
    310313        # We need to call the descriptor's __get__ to coerce this assigned
Back to Top