Last updated last month

Boolean fields store boolean values, as expected. It also provides convienence for accepting truthy or falsy values. See the usage section for more details.


from marrow.mongo.field import Boolean




This field type inherits all Field attributes and represents a singular, scalar boolean value. In addition to the storage and retrieval of pure True and False values, the field configuration defines allowable "truthy" values (to cast to True) and "falsy" values (to cast to False).


Values to interpret as True, storing True if they are assigned.

Default('true', 't', 'yes', 'y', 'on', '1', True)



Values to interpret as False, storing False if they are assigned.

Default('false', 'f', 'no', 'n', 'off', '0', False)


In versions prior to 1.1.3 the "truthy" and "falsy" values are hardcoded at the defaults presented above.


Instantiate and assign an instance of this class during construction of a new Document subclass. Accessing as a class attribute will return a Queryable allowing filtering operations, and access as an instance attribute will return a bool cast value.

Assignment of any value matched by the truthy iterable (via in comparison) will store True, and likewise with the falsy iterable storing False. Additionally, if an attempt is made to assign a non-boolean, non-string value, the value will be passed through bool() conversion prior to storage, allowing use of objects which define their own __nonzero__/__bool__ methods.