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

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

  •  
  •   zhuweiping · 2017-08-28 18:31:34 +08:00 · 2233 次点击
    这是一个创建于 2440 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如下图的方法运行 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 条回复    2017-08-28 19:07:43 +08:00
    zhuweiping
        1
    zhuweiping  
    OP
       2017-08-28 19:07:43 +08:00
    sorry 各位,这个问题不准确。完整的代码是在 firstapp 里自定义了一个 manage.py 命令,里面调用了 server.start_web_server,在用 manage.py + 自定义命令时指定了--settings=firstapp.settings。
    因为是在分析别人的代码,在这个地方卡了一段时间,自己掉坑里把这个给疏忽了。
    抱歉了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2282 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 15:15 · PVG 23:15 · LAX 08:15 · JFK 11:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.