Yield generated for 6e3a0049-be2c-455f-a40b-ed7a2cd08136
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
668 B

from marshmallow import Schema, fields, pre_load, post_dump
class ProfileSchema(Schema):
username = fields.Str()
email = fields.Email()
password = fields.Str(load_only=True)
bio = fields.Str()
image = fields.Url()
following = fields.Boolean()
# ugly hack.
profile = fields.Nested('self', exclude=('profile',), default=True, load_only=True)
@pre_load
def make_user(self, data, **kwargs):
return data['profile']
@post_dump
def dump_user(self, data, **kwargs):
return {'profile': data}
class Meta:
strict = True
profile_schema = ProfileSchema()
profile_schemas = ProfileSchema(many=True)