Skip to content

Commit

Permalink
feat: make package compatible with Django 2.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
santi committed Feb 23, 2020
1 parent db32492 commit 4462d8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import find_packages

setup(name="django-sorl-cropping",
version="0.1.0",
version="0.1.1",
description="A reusable app for cropping images easily and non-destructively in Django",
long_description=open('README.rst').read(),
author="Ilya Chistyakov",
Expand Down
12 changes: 6 additions & 6 deletions sorl_cropping/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ class Media:


class ImageCropWidget(AdminFileWidget, CropWidget):
def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if not attrs:
attrs = {}
if value:
attrs.update(get_attrs(value, name))
return super(AdminFileWidget, self).render(name, value, attrs)
return super(AdminFileWidget, self).render(name, value, attrs, renderer)


class HiddenImageCropWidget(ImageCropWidget):
def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if not attrs:
attrs = {}
# we need to hide it the whole field by JS because the admin
# doesn't yet support hidden fields:
# https://code.djangoproject.com/ticket/11277
attrs['data-hide-field'] = True
return super(HiddenImageCropWidget, self).render(name, value, attrs)
return super(HiddenImageCropWidget, self).render(name, value, attrs, renderer)


class CropForeignKeyWidget(ForeignKeyRawIdWidget, CropWidget):
Expand All @@ -85,7 +85,7 @@ def __init__(self, *args, **kwargs):

super(CropForeignKeyWidget, self).__init__(*args, **kwargs)

def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if attrs is None:
attrs = {}

Expand All @@ -104,4 +104,4 @@ def render(self, name, value, attrs=None):
except AttributeError:
logger.error("Object %s.%s doesn't have an attribute named '%s'." % (
app_name, model_name, self.field_name))
return super(CropForeignKeyWidget, self).render(name, value, attrs)
return super(CropForeignKeyWidget, self).render(name, value, attrs, renderer)

0 comments on commit 4462d8d

Please sign in to comment.