matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.26k stars 276 forks source link

get_field_info broken on a ProcessedImageField #499

Open tyrylu opened 4 years ago

tyrylu commented 4 years ago

At least in 4.0.2 imagekit.utils.get_field_info fails to get the instance in a spec associated with a ProcessedImageField. It worked in the past (not sure exactly with which version, unfortunately). Or, is there a different way how to access the current model instance from the associated spec?

vstoykov commented 4 years ago

Can you give more details (code sample) which can be used to reproduce the issue?

tyrylu commented 4 years ago

Nothing really fancy, basically just a modified version of the 3.x advanced docs example. In a model: image = ProcessedImageField(verbose_name=_("image"), default=NO_IMAGE_PATH, upload_to="productimages", autoconvert=None, spec=OptionalWatermarkSpec) And in the spec:

@property
    def processors(self):
        instance, field_name = get_field_info(self.source)

And get_field_info is the one from imagekit.utils. However, instance is None under Imagekit 4.0.2 and Django 3.0.4.