【发布时间】:2013-11-07 02:20:26
【问题描述】:
我在 Django 中的文件夹结构如下:
./project_root
./app
./fixtures/
./static/
./templates/
./blog/
./settings.py
./urls.py
./views.py
./manage.py
./__init__.py
./plugin
./code_editor
./static
./templates
./urls.py
./views.py
./__init__.py
./code_viewer
./static
./templates
./urls.py
./views.py
./__init__.py
那么我如何更改 settings.py 以动态加载插件(这意味着我不知道将在不同的服务器上安装多少插件。它应该在运行时动态检查并添加它。)on:
python manage.py runserver
我应该更改 ROOT_URLSCONF 吗?或 INSTALLED_APPS?谢谢你的回答。
【问题讨论】:
-
您需要将应用程序/插件添加到
INSTALLED_APPS,并且您需要在项目目录中的urls.py中包含应用程序的url。 -
@void 是否可以动态制作?我现在可以手动了。添加到 ROOT_URLCONF 并给它几个值怎么样?