#11196: dimensions not set when value for ImageField specifed in constructor ------------------------------------------+--------------------------------- Reporter: gwilson | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- Given a model with an `ImageField` and defined height/width fields, ex.
{{{ class Person(models.Model): name = models.CharField(max_length=50) mugshot = ImageField(storage=temp_storage, upload_to='tests', height_field='mug_height', width_field='mug_width') mug_height = models.PositiveSmallIntegerField() mug_width = models.PositiveSmallIntegerField() }}} Dimensions fields aren't set if you do: {{{ p = Person(name='Joe', mugshot=ImageFile(open(...))) }}} Actually, they are getting set when the `ImageField` gets the value assigned in `Model.__init__()` (using the `ImageFileDescriptor`), but since the height and width fields are defined after the `ImageField`, they get set back to `None` by `Model.__init__()`. After calling save on the instance: {{{ p.save() }}} ...the dimensions fields are set because `save()` ends up calling `ImageFileDescriptor.__set__()`, which updates the dimensions fields. This is related to #10044, #10404, and #11084. -- Ticket URL: <http://code.djangoproject.com/ticket/11196> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---