首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
DRF 中, 一个 resource 对应多个 model, 通常如何处理?
chaleaochexist
·
2019-03-12 22:55:29 +08:00
· 1249 次点击
这是一个创建于 2033 天前的主题,其中的信息可能已经有所发展或是发生改变。
如果一个 api 对应一个 model
就可以使用 generic view 或者 viewset 处理.
但是一个 api 对应多个 model
queryset 怎么写?
=========================
所以我们只能用 apiView 了是吗?
还有其他办法吗?
model
API
对应
queryset
3 条回复
•
2019-03-13 17:28:19 +08:00
1
neoblackcap
2019-03-13 10:06:14 +08:00
APIView 解决一切,我以前就是这样写的
2
chaleaochexist
OP
2019-03-13 17:26:35 +08:00
@
neoblackcap
嗯 搜了一圈 感觉大家都是这么用的...
那 viewset 其实没啥大用啊...
3
neoblackcap
2019-03-13 17:28:19 +08:00
@
chaleaochexist
curd 接口很有用
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
2216 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms ·
UTC 13:09
·
PVG 21:09
·
LAX 06:09
·
JFK 09:09
Developed with
CodeLauncher
♥ Do have faith in what you're doing.