diff --git a/imagekit/admin.py b/imagekit/admin.py index 94d9cf5..ebab76c 100644 --- a/imagekit/admin.py +++ b/imagekit/admin.py @@ -21,9 +21,9 @@ class AdminThumbnail(object): self.template = template def __call__(self, obj): - thumbnail = getattr(obj, self.image_field, None) - - if not thumbnail: + try: + thumbnail = getattr(obj, self.image_field) + except AttributeError: raise Exception('The property %s is not defined on %s.' % \ (self.image_field, obj.__class__.__name__)) diff --git a/imagekit/templates/imagekit/admin/thumbnail.html b/imagekit/templates/imagekit/admin/thumbnail.html index 6531391..adaa89f 100644 --- a/imagekit/templates/imagekit/admin/thumbnail.html +++ b/imagekit/templates/imagekit/admin/thumbnail.html @@ -1,3 +1,5 @@ - - - \ No newline at end of file +{% if thumbnail %} + + + +{% endif %} \ No newline at end of file