사용 예시!
# from datetime import datetime
from marshmallow import fields
from marshmallow_sqlalchemy import ModelSchema
#import from other folder
from .models.user_model import User
from .models.participant_model import Participant
from .models.vote_model import Vote
from .models.restaurant_model import Restaurant
from .models.poll_model import Poll
from .models.category_model import Category
class UserSchema(ModelSchema):
class Meta:
model = User
users_schema = UserSchema(many=True)
class ParticipantSchema(ModelSchema):
class Meta:
model = Participant
participant_schema = ParticipantSchema(many=True)
class VoteSchema(ModelSchema):
class Meta:
model = Vote
vote_schema = VoteSchema(many=True)
class RestaurantSchema(ModelSchema):
class Meta:
model = Restaurant
restaurant_schema = RestaurantSchema(many=True)
class PollSchema(ModelSchema):
class Meta:
model = Poll
poll_schema = PollSchema(many=True)
class CategorySchema(ModelSchema):
class Meta:
model = Category
category_schema = CategorySchema(many=True)
'Flask' 카테고리의 다른 글
Flask ORM (0) | 2021.05.11 |
---|---|
플라스크 기본 연습용 프로젝트 (0) | 2021.05.11 |
Restful API (flask) (3) | 2021.05.11 |
Flask 로 서버 연동 체크 (0) | 2020.07.21 |