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

django 里多个 App,每个 App 里都有自己的 settings.py 怎么生效的?

  •  
  •   zhuweiping · Aug 28, 2017 · 3089 views
    This topic created in 3218 days ago, the information mentioned may be changed or developed.
    如下图的方法运行 Django 应用,firstapp 里有自己的 settings 文件,其中导入了 mysite.settings,也定制了私有配配置项,firstapp.server 里传给 WSGIServer 的 application 是 mysite.wsgi.application,这个 application 在 django 内生成过程中需要配置文件的地方用的应该是 mysite.settings 配置文件吧? mysite.settings.INSTALLED_APPS 里没有添加 firstapp 也没有设置 firstapp 的 urls。小弟有个疑问:firstapp.settings 里的配置项是怎么生效的?
    ps:这么拉起来能够正常访问 firstapp 应用的。
    http://imgur.com/XRUuEGg
    http://imgur.com/c11qGGo
    1 replies    2017-08-28 19:07:43 +08:00
    zhuweiping
        1
    zhuweiping  
    OP
       Aug 28, 2017
    sorry 各位,这个问题不准确。完整的代码是在 firstapp 里自定义了一个 manage.py 命令,里面调用了 server.start_web_server,在用 manage.py + 自定义命令时指定了--settings=firstapp.settings。
    因为是在分析别人的代码,在这个地方卡了一段时间,自己掉坑里把这个给疏忽了。
    抱歉了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1081 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:06 · PVG 02:06 · LAX 11:06 · JFK 14:06
    ♥ Do have faith in what you're doing.