Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerinisready/9d92e3c29e6596a88b045f729a5c8fdc to your computer and use it in GitHub Desktop.
Save jerinisready/9d92e3c29e6596a88b045f729a5c8fdc to your computer and use it in GitHub Desktop.
django image store as blob in models.py
class imageStorageAsThumpnail(models.Model)
image = models.ImageField(_("Image"), upload_to='chapter_images')
_thumbnail = models.TextField(
db_column='thumbnail',
blank=True)
def set_thumbnail(self, data):
self._data = base64.b64encode(data)
def get_thumbnail(self):
return base64.b64decode(self._data)
thumbnail = property(get_thumbnail, set_thumbnail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment