From decf57f0fec6c423340c54f2ebb642c4a41dd813 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Mon, 18 Jun 2018 18:53:59 +0200 Subject: [PATCH] ReFix le AESField --- preferences/aes_field.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/preferences/aes_field.py b/preferences/aes_field.py index 302aa82b..1329b0a7 100644 --- a/preferences/aes_field.py +++ b/preferences/aes_field.py @@ -79,6 +79,12 @@ class AESEncryptedField(models.CharField): return decrypt(settings.AES_KEY, binascii.a2b_base64(value)).decode('utf-8') + def from_db_value(self, value, *args, **kwargs): + if value is None: + return value + return decrypt(settings.AES_KEY, + binascii.a2b_base64(value)).decode('utf-8') + def get_prep_value(self, value): if value is None: return value