推荐学习书目
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 · Mar 12, 2019 · 1625 views
    This topic created in 2628 days ago, the information mentioned may be changed or developed.
    如果一个 api 对应一个 model
    就可以使用 generic view 或者 viewset 处理.

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

    =========================
    所以我们只能用 apiView 了是吗?
    还有其他办法吗?
    3 replies    2019-03-13 17:28:19 +08:00
    neoblackcap
        1
    neoblackcap  
       Mar 13, 2019
    APIView 解决一切,我以前就是这样写的
    chaleaochexist
        2
    chaleaochexist  
    OP
       Mar 13, 2019
    @neoblackcap 嗯 搜了一圈 感觉大家都是这么用的...
    那 viewset 其实没啥大用啊...
    neoblackcap
        3
    neoblackcap  
       Mar 13, 2019
    @chaleaochexist curd 接口很有用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2808 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 12:51 · PVG 20:51 · LAX 05:51 · JFK 08:51
    ♥ Do have faith in what you're doing.