diefenbach / django-lfs

An online-shop based on Django
http://www.getlfs.com
BSD 3-Clause "New" or "Revised" License
622 stars 222 forks source link

Custom ImageWithThumbsField field and migrations issue #184

Closed pigletto closed 9 years ago

pigletto commented 9 years ago

LFS uses custom ImageWithThumbsField. This fields adds 'sizes' attribute that was referenced by south migrations: https://github.com/diefenbach/django-lfs/blob/master/lfs/core/fields/thumbs.py#L157

With Django 1.7 + there is a 'deconstruct' method that does the same thing, so for ImageWithThumbsField it should be:

def deconstruct(self):
    name, path, args, kwargs = super(ImageWithThumbsField, self).deconstruct()
    # Only include kwarg if it's not the default
    if self.sizes is not None:
        kwargs['sizes'] = self.sizes
    return name, path, args, kwargs

We should remove old 'south' code that is now unnecessary and add deconstruct method. After deconstruct method is defined there is a need to generate new migrations for all models using ImageWithThumbsField. I'm not really sure if having 'sizes' in migrations changes anything but for the sake of clarity I think it should be added with deconstruct method. Thoughts?

diefenbach commented 9 years ago

Go on! Thx for bringing this up!