Opened 10 years ago

Closed 10 years ago

#1026 closed defect (wontfix)

Set width and height failed when saving a upload image through the function 'save_*_file'

Reported by: leo@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


An exception is thrown out when you use the function 'save_*_file' to save an upload image file.

Traceback (most recent call last):

File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/django/utils/", lin e 3, in _curried

return args[0](*(args[1:]+moreargs), dict(kwargs.items() + morekwar gs.items()))

File "/usr/lib/python2.3/site-packages/django/core/meta/", l ine 1302, in method_save_file

setattr(self, field.width_field, width)

TypeError: attribute name must be string

Fix patch:
--- django/core/meta/ (revision 1566)
+++ django/core/meta/ (working copy)
@@ -1303,9 +1303,9 @@

from django.utils.images import get_image_dimensions
width, height = get_image_dimensions(getattr(self, 'get_%s_filename' %
if field.width_field:

  • setattr(self, field.width_field, width)

+ setattr(self, '%s.width_field' % field, width)

if field.height_field:

  • setattr(self, field.height_field, height)

+ setattr(self, '%s.height_field' % field, height)

Attachments (1)

fix.patch (740 bytes) - added by leo@… 10 years ago.

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by leo@…

comment:1 Changed 10 years ago by Malcolm Tredinnick <malcolm@…>

  • Resolution set to wontfix
  • Status changed from new to closed

This patch is not valid. The height_field and width_field attributes are already strings (holding the names of the fields used to store the height and width).

Somebody reported on IRC, too, but it was impossible to repeat on any other installation and went away after an sqlreset or something similar. So I'm going to close this as wontfix for now, but if you can come up with a repeatable test case, please reopen.

Note: See TracTickets for help on using tickets.
Back to Top