Lib marshmallow advanced
Project description
Marshmallow advanced Python library
Extra fields
Active field
Converts active
field to state
and back.
>>> class SimpleSchema(Schema):
active = Active()
>>> SimpleSchema().dump({'state': 'active'})
{'active': True})
>>> SimpleSchema().dump({'state': 'inactive'})
{'active': False}
>>> SimpleSchema().load({'active': True})
{'state': 'active'}
>>> SimpleSchema().load({'active': False})
{'state': 'inactive'}
Filter by query parameter:
>>> class SimpleFilterSchema(Schema):
active = Active(as_filter=True)
>>> SimpleFilterSchema().load({'active': 'true'})
{'state': 'active'}
>>> SimpleFilterSchema().load({'active': 'false'})
{'state': 'inactive'}
>>> SimpleFilterSchema().load({})
{'state__ne': 'deleted'}
For experienced usage try positives
, negatives
, positive_filter
,
negative_filter
, missing_filter
parameters. You can see behaviour for this parameters in tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for marshmallow_advanced-1.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae75b02de042571e0393f23fed11fa60713fcb7f4f99e035c36049e79262f835 |
|
MD5 | e27352d799fa9ee2efeec2c616c3b8be |
|
BLAKE2b-256 | 69a3f138de5fb4dc84b2850ca876e7edab2fed24c8fc342f857149ad13b7058c |