﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18543	Non image file can be saved to ImageField	johnsmith		"https://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield
    Inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image.


I was trying to find out the exact exception that would be raised if a file is not an image and it appears that no such image validation is done. So I did a test, with a model such as this
{{{
class Image(models.Model):
    caption = models.Charfield(max_length=60)
    image = models.ImageField(upload_to='somewhere')

}}}

I tried this
{{{
f = django.core.files.base.ContentFile('not an image')
i = myapp.models.Image()
i.caption(""This should throw an error but doesn't"")
i.image.save('bar.jpg', f)
i.save()
}}}

I don't get any errors and the file is saved. Maybe I'm doing something wrong but from what the docs say I'm expecting to be prevented from doing this.

From pip freeze
Django==1.4
PIL==1.1.7


"	Bug	new	Database layer (models, ORM)	1.4	Normal			niwi@… deprince@…	Accepted	0	0	0	0	0	0
