After I attempt to put a zlibbed string in models.TextField

>>> f = VCFile(head = 'blahblah'.encode('zlib'))

it fails:

raise DjangoUnicodeDecodeError(s, *e.args)
DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 1: unexpected code byte. You passed in 'x\x9cK\xcaI\xccH\x02b\x00\x0eP\x03/' (<type 'str'>)

Can there be in whatever way to repair this (aside from getting away the string - it needs to be space-efficent)?

Like Marcus states, you will need to use BLOB if you wish to ensure that it stays in binary format. If you are Comfortable with encoding it, you should use base64 encoding:

from base64 import binascii

f = VCFile(head = binascii.b2a_base64('blahblah'.encode('zlib')))

During my very fundamental tests with 33k figures, the zlib string was 28% how big the initial string, the base64 encoded zlib string was 37% how big the initial string. Less than nearly as good on compression, but nonetheless a large improvement.

If you won't want to scribe it, you need to store it as being a binary object (BLOB), not really a string. Django does not appear to aid BlobFields as they are, so go think it is around the internet or hack something together.