Django

Code

Ticket #1964 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

[patch] Fetching the dimensions of an ImageField

Reported by: Armin Ronacher <armin.ronacher@active-4.com> Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

patch-django-db-models-dimensions-get_FIELD_filename (0.6 kB) - added by anonymous on 05/22/06 18:15:11.

Change History

05/22/06 18:15:11 changed by anonymous

  • attachment patch-django-db-models-dimensions-get_FIELD_filename added.

05/22/06 18:15:54 changed 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/base.py

05/25/06 02:17:39 changed by anonymous

  • summary changed from Fetching the dimensions of an ImageField to [patch] Fetching the dimensions of an ImageField.

06/19/06 23:12:27 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #1964 ([patch] Fetching the dimensions of an ImageField)




Change Properties
Action