0

我有一个带有数据库的烧瓶应用程序。我需要在那里本地化某些类型的实体。问题是,我正在使用 Flask-Marshmallow 来解析/序列化我的数据库对象。还有一个端点,它抓取根对象(用户)及其所有相关的嵌套对象(匹配),然后它又抓取它的相关对象(问题),我需要对其进行本地化。因此,具有 Accept-Language 标头不能直接传递给 nested->nested (Question) 对象。我相信这是一些架构问题,而不是技术问题。如果有人遇到过这样的问题并且知道任何解决方法,请告诉我。

# views.py
@app.route('/self', methods=['GET'])
@auth.login_required
def get_user:
    user = g.user
    schema = UserSchema()
    res = schema.dumps(user)

# UserSchema.py
class UserSchema(marshmallow.Schema):
    id = fields.Int()
    matches = fields.Nested('MatchSchema', many=True)
    // etc.
4

0 回答 0