base64 encoding/decoding property for storing binary data in Django TextFields.
This is possibly the simplest solution for storing binary data in a TextField.
- django
- model
- field
- base64
- blob
This is possibly the simplest solution for storing binary data in a TextField.
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'