在 Django 中,如何在项目外的新应用程序中重用 settings.py
我正在开发一个新的 Django 应用程序。
我有以下目录结构。
Django/
appc
project1
appA
appB
我想使用appc 中project1 中的settings.py。我已将 appc 应用程序添加到 project1 下的 INSTALLED_APPS 中。我正在使用 WSGI,因此我也将 Django/appc 目录添加到 python 路径中。
当我尝试从 appA 扩展模板时,我的问题出现了,我无法加载 project1 settins.py 中定义的任何变量。所以我想我的问题是如何确保 appC 将从 appB 获取设置?
I have a new Django application I am working on.
I have the following directory structure.
Django/
appc
project1
appA
appB
I would like to use the settings.py from project1 in appc. I have added the appc application to the INSTALLED_APPS under project1. I am using WSGI so I added the Django/appc directory to the python path as well.
My problem comes in when I try and extend a template from appA I am not able to load any of the Variables defined in the project1 settins.py. So I guess my question is then how can I ensure that appC is going to source the settings from appB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要访问项目设置的 Django 应用程序应导入并使用
django.conf.settings
。Django apps that require access to the project settings should import and use
django.conf.settings
.