Login

Tag "blob"

Snippet List

Base64Field: base64 encoding field for storing binary data in Django TextFields

This Base64Field class can be used as an alternative to a BlobField, which is not supported by Django out of the box. The base64 encoded data can be accessed by appending _base64 to the field name. This is especially handy when using this field for sending eMails with attachment which need to be base64 encoded anyways. **Example use:** class Foo(models.Model): data = Base64Field() foo = Foo() foo.data = 'Hello world!' print foo.data # will 'Hello world!' print foo.data_base64 # will print 'SGVsbG8gd29ybGQh\n'

  • django
  • model
  • field
  • base64
  • blob
  • base64field
Read More

2 snippets posted so far.