Extended Marshmallow library
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_extended-1.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b5d53f4c0c55218f4f2b1ad2adb88a723ab3095c7406533ac9ff0f5782cdc0 |
|
MD5 | cd8f13b88b9b10ff94956a35db57a096 |
|
BLAKE2b-256 | ea9e06c6507b3a511da511b080399a1f0500cacb705e6587626244ee4d619ee5 |