I'm trying to write a validator for a Django-CMS FilerImageField
. The following validator function is used for a default ImageField
. When I copy it to the new Model, it will crash with the message 'int' object has no attribute 'file'
. Obviously a different type of value is being passed to the validator function. I can't seem to find information on what kind of data is being passed to the validator. How do I correctly reference the file so I can get_image_dimensions()
?
def validate(fieldfile_obj):
width, height = get_image_dimensions(fieldfile_obj.file) #crash
if width > 1000:
raise ValidationError("This is wrong!")