class TestSchema(ModelSchema): foreign_key_field = fields.RelatedNested(FKNestedSchema, required=False, allow_none=True) many_to_many_field = fields.RelatedNested(M2MNestedSchema, many=True) one_to_one_field = fields.RelatedNested(O2ONestedSchema) class Meta: model = db_models.AllRelatedFieldsModel fields = ('name', 'foreign_key_field', 'many_to_many_field', 'one_to_one_field')
class TestSchema(ModelSchema): many_to_many_field = fields.RelatedNested(M2MSchema, many=True) class Meta: model = db_models.AllRelatedFieldsModel fields = ('name', 'many_to_many_field')
class TestSchema(ModelSchema): foreign_key_field = fields.RelatedNested(ForeignKeySchema) class Meta: model = db_models.AllRelatedFieldsModel fields = ('name', 'foreign_key_field')
class TestSchema(ModelSchema): one_to_one_field = fields.RelatedNested(O2ONestedSchema) class Meta: model = db_models.AllRelatedFieldsModel fields = ('name', 'foreign_key_field', 'many_to_many_field', 'one_to_one_field')