Django does not have a BinaryField?, or BlobField? or whatever you want to call it, which is a bit sad.
In 0.96 and before it however worked to insert into blob fields with custom SQL though. In the SVN-release this is broken.
An example from my code.
info_hash is a blob field (mysql)
def create_xbt_file(info_hash, timestamp):
query = "INSERT INTO xbt_files (info_hash, mtime, ctime) VALUES (%s, %s, %s)"
from django.db import connection
cursor = connection.cursor()
cursor.execute(query, [info_hash, timestamp, timestamp])
This throws a nasty UnicodeDecodeError? whenever a byte with a position between 45-50 (among others I guess) is in info_hash.
If I bypass django completely using MySQLdb, then it works fine
def create_xbt_file(info_hash, timestamp):
import MySQLdb
db = MySQLdb.connect("localhost", DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)
cursor = db.cursor()
query = "INSERT INTO xbt_files (info_hash, mtime, ctime) VALUES (%s, %s, %s)"
cursor.execute(query, [info_hash, timestamp, timestamp])
db.close()