jonasundderwolf / django-image-cropping

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

Crop area is not recorded on object creation in Django Admin for Proxy models #181

Open agsimmons opened 1 year ago

agsimmons commented 1 year ago

Hi!

I've noticed that if you create a proxy model that has an ImageField and an ImageRatio field, the crop field's value is not set upon saving for the first time. For non-proxy models, the crop field's value is set.

I've confirmed that if the object has already been created, then the image is added, the crop value is set upon save.

Django version tested: 3.2.16 Python version tested: 3.10 django-image-cropping version tested: 1.7

I've set up https://github.com/agsimmons/django-image-cropping-proxy-bug to demonstrate the bug

Steps to reproduce with the above repository

  1. Clone repository
  2. Create virtual environment
  3. Install packages in requirements.txt
  4. Apply migrations
  5. Create superuser account
  6. Run the development server
  7. Log in to admin interface at 127.0.0.1:8000/admin/
  8. Create an example model instance. Provide a name and image. Press Save.
  9. Observe in the list view that the Image Cropping field has a value set.
  10. Create an example proxy model instance. Provide a name and image. Press Save.
  11. Observe in the list view that the Image Cropping field does not have a value set.
  12. Select the proxy model instance that you just created. Press Save.
  13. Observe in the list view that the Image Cropping field now has a value set.