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
chaleaochexist
V2EX  ›  Python

DRF 中, 一个 resource 对应多个 model, 通常如何处理?

  •  
  •   chaleaochexist · 2019-03-12 22:55:29 +08:00 · 1177 次点击
    这是一个创建于 1843 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如果一个 api 对应一个 model
    就可以使用 generic view 或者 viewset 处理.

    但是一个 api 对应多个 model
    queryset 怎么写?

    =========================
    所以我们只能用 apiView 了是吗?
    还有其他办法吗?
    3 条回复    2019-03-13 17:28:19 +08:00
    neoblackcap
        1
    neoblackcap  
       2019-03-13 10:06:14 +08:00
    APIView 解决一切,我以前就是这样写的
    chaleaochexist
        2
    chaleaochexist  
    OP
       2019-03-13 17:26:35 +08:00
    @neoblackcap 嗯 搜了一圈 感觉大家都是这么用的...
    那 viewset 其实没啥大用啊...
    neoblackcap
        3
    neoblackcap  
       2019-03-13 17:28:19 +08:00
    @chaleaochexist curd 接口很有用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1010 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:55 · PVG 03:55 · LAX 12:55 · JFK 15:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.