I have to display a set of images for the client to use them as a reference.
I have tried using fields.Binary() and wrote a class method as below
photo = fields.Binary('phtoto') @classmethod def convert_photo(cls, data): if data and Image: image = Image.open(BytesIO(data)) image.thumbnail((200, 200), Image.ANTIALIAS) data = BytesIO() image.save(data, image.format) data = fields.Binary.cast(data.getvalue()) return data
Now, this works well if I want to upload an image and display.
How do I give a default Binary image and display it to the client?
Do I have to give a default method, if so how, with an example. Else any other better way to do it
Have a nice day