Wanjohi254
Wanjohi254

Reputation: 39

Errors using Django Awesome Avatar

Have been trying to solve an issue using Django awesome avatar. I have used the AvatarField() in my models to save the profile pic in the UserProfile model.

avatar = AvatarField(upload_to=upload_profile, width=100, height=100,default = 'profiles/profile.jpg',)

Have also used a ModelForm to render the field to a form that is shown on the templates

avatar = avatar_forms.AvatarField()

When I try to access the user profile in admin and save, it throws an error:

'ImageFieldFile' object has no attribute '__getitem__'

Also, when I select a photo on the form in template, it does not show the crop tool that am supposed to use to resize the image.

Upvotes: 0

Views: 148

Answers (1)

renno
renno

Reputation: 2827

Are you trying to access the file name?

You should use something like this:

def __unicode__(self):
    return unicode(self.image_location)

source: Django image field throws TypeError

Upvotes: 0

Related Questions