推荐学习书目
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
stackpop
V2EX  ›  Python

Django那么多view,都写在同一个文件里面吗?

  •  
  •   stackpop ·
    sjtubinlong · Sep 7, 2012 · 4657 views
    This topic created in 5015 days ago, the information mentioned may be changed or developed.
    发现越写越雍炯了~~~~~~~~~~

    有没有一些类似于最佳实践的tips呢
    2 replies    1970-01-01 08:00:00 +08:00
    kollinchu
        1
    kollinchu  
       Sep 7, 2012
    可以建立一个Views的package,按照你需要,组织文件,不一定非要写到views.py
    这里有一篇可以参考一下:http://lincolnloop.com/django-best-practices/
    这里还有一个翻译版本:https://github.com/brantyoung/zh-django-best-practices
    Js
        2
    Js  
       Sep 7, 2012   ❤️ 1
    尽量拆分app

    分不了的话views不一定是views.py, 也可以是

    views/__init__.py
    """
    from .a import *
    from .b import *
    """
    views/a.py
    views/b.py

    发挥想象力嘛....
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5500 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 82ms · UTC 08:13 · PVG 16:13 · LAX 01:13 · JFK 04:13
    ♥ Do have faith in what you're doing.