triump0870 triump0870 - 1 month ago 16
Python Question

django-image-cropping not working in admin interface

I'm using django-image-cropping in my django project and I followed the official guidelines but still I'm not getting the desired result.
Here the snippet of my project files.

I already added

to my

from easy_thumbnails.conf import Settings as thumbnail_settings
) + thumbnail_settings.THUMBNAIL_PROCESSORS

from django.db import models
from image_cropping import ImageRatioField
class UserData(models.Model):
fullname = models.CharField(max_length=255)
user = models.CharField(max_length=70, unique=True, blank=False, null=False)
image = models.ImageField(upload_to=generate_filename,blank=False, null=False)
cropping = ImageRatioField('image', '180x180')

from django.contrib import admin
from image_cropping import ImageCroppingMixin
class UserDataModelAdmin(ImageCroppingMixin, admin.ModelAdmin):
# filter_horizontal=['image']
pass, UserDataModelAdmin)

As per the official guidelines its enough to see the enhanced selection area in the admin panel, but I'm not getting it. Instead I'm getting this.
enter image description here

No option for cropping.

Please help me to sort this out.


Use this tool django-imagekit-cropper, it has nice features and very good documentation. you need to create a file and need to mention this

from django import forms
    from imagekit_cropper.widgets import ImageCropWidget    
    from .models import UserData

    class ImageAdminForm(forms.ModelForm):
        square_150_crop = forms.CharField(widget=ImageCropWidget(properties=Image.square_150_crop_properties,['square_150_crop']))

        class Meta:
            model = UserData