Opened 18 years ago

Closed 18 years ago

Last modified 18 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: dev
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

Description

>>> 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/functional.py", 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/base.py", 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/base.py", 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 18 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by anonymous, 18 years ago

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/base.py

comment:2 by anonymous, 18 years ago

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

comment:3 by Adrian Holovaty, 18 years ago

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