Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1964 closed defect (fixed)

[patch] Fetching the dimensions of an ImageField

Reported by: Armin Ronacher <armin.ronacher@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


>>> i.get_source_width()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/utils/", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
  File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/", line 344, in _get_FIELD_width
    return self._get_image_dimensions(field)[0]
  File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/", line 353, in _get_image_dimensions
    filename = self._get_FIELD_filename(field)()
TypeError: 'str' object is not callable

where "i" is an instance of an model with a ImageField called source. AFARI the problem is the () after the _get_FIELD_filename call which returns the filename.

Attachments (1)

patch-django-db-models-dimensions-get_FIELD_filename (592 bytes) - added by anonymous 13 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 13 years ago by anonymous

yeah, i've hit this one to.

dealing with a lot of image fields in my models i've
fixed the () and everything works fine :)

for people wanting a quick fix i've attached a patch to django/db/models/

comment:2 Changed 13 years ago by anonymous

Summary: Fetching the dimensions of an ImageField[patch] Fetching the dimensions of an ImageField

comment:3 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [3168]) Fixed #1964 -- Fixed bug in fetching the dimensions of an ImageField. Thanks, Armin Ronacher

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