'ImageFieldFile' object has no attribute 'startswith'

744 views
Skip to first unread message

Daehee

unread,
Aug 11, 2008, 3:22:10 PM8/11/08
to Django users
Hi, I'm using Django revision 8309. After I recently update to this
revision, it seems to break my code... Just wondering if anyone else
is having the same errors. I tried to roll back to a previous revision
but now the error seems stuck. Any help would be appreciated.

My code is:

{% load thumbnail %}
<div class="avatar"><img src="/media_files/{% thumbnail object.photo
180x180 crop %}" alt="{{ object.name }}'s photo" /></div>

The resulting error is:

TemplateSyntaxError at /people/daehee-park/
Caught an exception while rendering: 'ImageFieldFile' object has no
attribute 'startswith'

Michel Thadeu Sabchuk

unread,
Aug 11, 2008, 3:35:23 PM8/11/08
to Django users
Hi,

See the page above:

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Filestoragerefactoring

You need to change the thumbnail package. Where you get a call to
self.filename, you should change to self.filename.name...

Best regards,

Marty Alchin

unread,
Aug 11, 2008, 3:37:02 PM8/11/08
to django...@googlegroups.com
On Mon, Aug 11, 2008 at 3:22 PM, Daehee <dae...@gmail.com> wrote:
> Hi, I'm using Django revision 8309. After I recently update to this
> revision, it seems to break my code... Just wondering if anyone else
> is having the same errors. I tried to roll back to a previous revision
> but now the error seems stuck. Any help would be appreciated.

This would have been introduced in revision 8244, with the FileField
changes. Values for FileField are no longer raw strings, so they don't
have the startswith() method anymore. I was told last night that some
of the thumbnail apps rely on startswith(), and are thus breaking.

The solution here is to update the thumbnail app to use the value's
"name" attribute as the string it wants.

-Gul

Daehee

unread,
Aug 11, 2008, 3:59:47 PM8/11/08
to Django users
Thank you for the prompt responses. I am using sorl-thumbnail on
Google Code, and with your tips I found the solution to the problem
based on the FileField refactoring here: http://code.google.com/p/sorl-thumbnail/issues/detail?id=34

Daehee

YusufSalahAdDin

unread,
May 22, 2015, 12:05:56 AM5/22/15
to django...@googlegroups.com, dae...@gmail.com
I have the same problem doing feeds, can anyone help me?
Yes, i'm using sorl-thumbnail.
Reply all
Reply to author
Forward
0 new messages