File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11# Changelog for django-pgcrypto
22
3+ ## 3.0.4 (unreleased)
4+
5+ * Added ` EncryptedBooleanField `
6+
37## 3.0.3 (2025-02-04)
48
59* Added ` iexact ` lookup (https://github.com/dcwatson/django-pgcrypto/pull/39 )
Original file line number Diff line number Diff line change @@ -255,6 +255,22 @@ def formfield(self, **kwargs):
255255 return super ().formfield (** defaults )
256256
257257
258+ class EncryptedBooleanField (BaseEncryptedField ):
259+ description = _ ("Boolean" )
260+ field_cast = "::boolean"
261+
262+ def formfield (self , ** kwargs ):
263+ defaults = {"form_class" : forms .BooleanField }
264+ defaults .update (kwargs )
265+ return super ().formfield (** defaults )
266+
267+ def to_python (self , value ):
268+ if value in self .empty_values :
269+ return None
270+ unencrypted_value = super ().to_python (value )
271+ return unencrypted_value == 'True'
272+
273+
258274class EncryptedLookup (Lookup ):
259275 patterns = {
260276 "contains" : "%%%s%%" ,
You can’t perform that action at this time.
0 commit comments