class GalleryItem(models.Model):
name = models.CharField(max_length=255, null=True, blank=True)
picture = models.ImageField(upload_to='pictures/%Y/%m/%d', blank=True)
class NewsItem(models.Model):
title = models.CharField(max_length=255)
picture = models.ForeignKey(GalleryItem, null=True, blank=True)
cropping = ImageRatioField('picture__picture', '120x100')
When we try to add a new register with an empty picture (because it's not required) we get the following error:
...image_cropping/fields.pyc in initial_cropping(self, sender, instance, *args, **kwargs)
101 if ratiofield.image_fk_field : # image is ForeignKey
102 # get the imagefield
--> 103 image = getattr(image, ratiofield.image_fk_field)
104 if not image:
105 continue
AttributeError: 'NoneType' object has no attribute 'picture'
Considering the following models:
When we try to add a new register with an empty picture (because it's not required) we get the following error:
I'm using: Django==1.6.6 django-image-cropping==0.9