BOMBOLOM.COM

(django) ImageField Validation Error

Posted by José Lopes.

While using the Django administration I've got the following validation error on the models.ImageField, despite the files being images:

Upload a valid image. The file you uploaded was either not an image or a corrupted image

This post shows a way to work around this problem.

I really don't have a precise idea about the cause of the exception, maybe its due to Django's developing stage. I'm using the last Django truck version, number 7519 on this post date, and the PIL (Python Imaging Library) version 1.1.4-298

In order to stop this validation error you must edit the file 'PATH to Djando's directory'/django/core/validators.py and comment the following lines on the isValidImage function:

trial_image = Image.open(StringIO(content))
trial_image.load()

The validation error stops when you update an image file.

The model works correctly only validating image files and displaying the error message if the file is not an image.

2008.05.05 | There's more... | Comments 0 | Tags , ,

Deixe a sua mensagem:

Nome:


E-mail:


URL:


Comment:

Secret number

To send you comment you must insert the "secret number" on the box


Made with PyBlosxom | Add to Google