Django admin: Cropping using ImageRatioField on FilerImageField give errors
When I am doing cropping using ImageField and ImageRatioField it working well for me but I have to do it with FilerImageField than it will not work for me.
class FeatureArticle(models.Model):
featured_listing_image = models.ImageField(
null=True,
blank=True,
upload_to=featured_listing_image_directory_path,
verbose_name=_('Feature listing image'),
help_text=_('Feature listing image of article.'),
)
featured_listing_image_cropping = ImageRatioField('featured_listing_image', '433x309', allow_fullsize=True, free_crop=False)
featured_listing_image_latest = FilerImageField(
null=True,
blank=True,
verbose_name=_('Featured listing image latest'),
help_text=_('Featured listing latest image of Article.')
)
featured_listing_image_latest_cropping = ImageRatioField('featured_listing_image_latest', '433x309', allow_fullsize=True,free_crop=False)
@property
def cropped_feature_listing_image(self):
if self.featured_listing_image:
featured_listing_image = self.featured_listing_image.url
image_name = featured_listing_image.split('/')[-1].split('.')[0]
featured_listing_image = featured_listing_image.replace(image_name, image_name + '_crop')
return featured_listing_image
return ''
from django.contrib import admin
from .model import FeatureArticle
from image_cropping import ImageCroppingMixin
class FeatureArticleInline(ImageCroppingMixin, admin.StackedInline):
model = FeatureArticle
max_num = 0
fieldsets = (
(_('Featured Image'), {
'fields': (
'featured_listing_image',
'featured_listing_image_cropping',
'featured_listing_image_latest',
'featured_listing_image_latest_cropping'
),
}),
)
But It will give error of when I trying using FilerImageField.
Error: There's no widget registered to the class FilerImageField.
Please give me a solutions of cropping of image possible with this two field type?
Thanks in advance.