jonasundderwolf / django-image-cropping

Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.
Other
553 stars 131 forks source link

ImageRatioField causes IntegrityError #58

Closed pmarcely closed 9 years ago

pmarcely commented 9 years ago

Hi guys,

I am using django 1.7. and its migrations. I did following steps: 1) Added 2 fields into my existing model company_logo = models.ImageField(null=True, blank=True, upload_to='logos') company_small_logo = ImageRatioField('company_logo', '150x150') 2) Ran makemigrations and it asked me to enter default value for company_small_logo. 3) After I ran migrate command it showed following error: django.db.utils.IntegrityError: table__new.company_small_logo may not be NULL

Actually, I managed to add ImageRatioField into new Model with zero rows, but all my attempts to extend the table with ImageRatioField failed. Adding 'null':True into field_kwargs in ImageRatioField.init method helped to solve the issue. Can you check this issue? Did I miss something that I had experienced integrityerror?

Thank you, Peter

bartgryszko commented 9 years ago

:+1: Same here.

anrie commented 9 years ago

I just realized that our docs are a bit misleading, as the ImageRatioField is a essentially a CharField and shouldn't be set to null. Same goes for the ImageField. (See this for example)

So we are going to fix that.

In Django 1.7 it is currently however necessary to set a default value for blankable fields. There is already a fix for that on master.

I see that we issue a new release in the next days.

pmarcely commented 9 years ago

Thanks, looking forward to test it.

Peter

anrie commented 9 years ago

@pmarcely Can you confirm that the issue is resolved when you use the latest (0.9.1) release?

pmarcely commented 9 years ago

@anrie It works well, thanks.