Can a model generate custom SQL when loading/saving a field?

2 views
Skip to first unread message

Tony Czeh

unread,
Nov 12, 2009, 11:40:33 AM11/12/09
to Django users
I'm running into a bit of a problem with Django's models. I have a
VARCHAR field that needs to be stored with the content AES_ENCRYPT
then HEXed (done on the MySQL server).

What I'd like to have happen is for the Django model to generate
"AES_DECRYPT(UNHEX(field), salt)" when the field is loded by the model
and "HEX(AES_ENCRYPT(field, salt))" when the field is saved by the
model.

Is there a way to make this happen, so far I'm not turning up
anything.

Cheers,
Tony Czeh
Reply all
Reply to author
Forward
0 new messages