I’m trying to add images to my models in my Django app.
models.py
class ImageMain(models.Model):
"""This is the Main Image of the product"""
product = models.ForeignKey(Product)
photo = models.ImageField(upload_to='products')
In development mode, every time I try to upload the image via Django admin, I keep getting:
Upload a valid image. The file you uploaded was either not an image or a corrupted image.
The jpg I’m trying to upload can be viewed with os X Preview so it would seem to be valid.
It seems the problem is Python Imaging Library doesn’t recognize it as an image. Why would that be happening with a valid image?
PIL is installed, verified via the Django shell.
According to Django’s source code. Those three lines are responsible for verifying images:
The image type could be unsupported by PIL. Check the list of supported formats here