V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
Macv1994
V2EX  ›  Python

关于 flask 中的 可插拔视图

  •  
  •   Macv1994 ·
    weijiang1994 · Oct 29, 2020 · 1896 views
    This topic created in 2017 days ago, the information mentioned may be changed or developed.

    在看 flask 文档的时候看到了这一节,不知道有没有巨佬可以解释一下,真正的实际用途在哪里。看了辉神的 flask 书,里面也没有用到这种写法。

    3 replies    2020-11-08 00:31:38 +08:00
    zhuangzhuang1988
        1
    zhuangzhuang1988  
       Oct 29, 2020
    大项目使用的.
    Macv1994
        2
    Macv1994  
    OP
       Oct 29, 2020
    @zhuangzhuang1988 好吧...
    johnsona
        3
    johnsona  
       Nov 8, 2020
    1.复用,比如你这里有个逻辑是列表查询,那里也有一个逻辑是列表查询,但就是数据表不一样,你就可以写一个 ListView,把共同逻辑写在父类,不同的地方也就是数据表,也就是 Model 交给子类实现。同样的查询哪些字段 分页 都可以,参考 django rest framework 的 view
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3306 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 12:52 · PVG 20:52 · LAX 05:52 · JFK 08:52
    ♥ Do have faith in what you're doing.