From dcc42c93262993deeb379a7ca2c498d38d60eb9d Mon Sep 17 00:00:00 2001 From: Scott Pashley Date: Wed, 23 Oct 2024 15:11:51 +0100 Subject: [PATCH] Since the field is always treated as TextField, we should return an empty string rather than None for those model fields that are not nullable. --- encrypted_fields/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encrypted_fields/fields.py b/encrypted_fields/fields.py index 03e5c45..3caba6d 100644 --- a/encrypted_fields/fields.py +++ b/encrypted_fields/fields.py @@ -54,7 +54,7 @@ class EncryptedFieldMixin(object): if not isinstance(value, str): value = str(value) return self.f.encrypt(bytes(value, "utf-8")).decode("utf-8") - return None + return "" def get_db_prep_value(self, value, connection, prepared=False): if not prepared: