# models.py def thumb_(self): tiny = path.join(path.dirname(self.get_img_filename()), 'thumb_' + path.basename(self.get_img_filename())) if not path.exists(tiny): im = Image.open(self.get_img_filename()) im.thumbnail(TINY_SIZE, Image.ANTIALIAS) im.save(tiny, 'JPEG') tiny_url = path.join(settings.MEDIA_URL, path.dirname(self.img), 'thumb_' + path.basename(self.img)) ancore = 'thumbnail of %s' % (self.get_img_url(), tiny_url, self.alt) return ancore thumb_.allow_tags = True thumb_.short_description = _('thumb') class Admin: list_display = ('product', 'thumb_', 'alt')