Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于orm的外键数据返回使用response_model的困惑 #4

Open
feixianghs opened this issue Apr 9, 2020 · 3 comments
Open

关于orm的外键数据返回使用response_model的困惑 #4

feixianghs opened this issue Apr 9, 2020 · 3 comments

Comments

@feixianghs
Copy link

请问,如何处理关联数据的展示,比如一对多的数据结构使用response_model,使用salalchemy可以实现,官网已经给了。但是你的demo里用的是orm,我出查了orm的官网,没找到相关文档,能麻烦给个例子学习下吗?

@wxq0309
Copy link
Owner

wxq0309 commented Apr 10, 2020

https://github.com/encode/orm
文档中已有类似ForeignKey的一对多外键关联,是否可以通过设置List[response_model]返回对应的数据?

@feixianghs
Copy link
Author

就是在用List的时候怎么试都不行,能加个好友交流吗,wx号feixiang-fomn

@zhimingzhang123
Copy link

@wxq0309 这个问题解决了吗, 我也有同样的问题。使用encode orm包时,没法嵌套序列化,sqlalchemy文档中可以使用

# schema.py

class Config:
    orm_mode = True

来解决,但是orm似乎不行,有好的方法吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants