django - 应用程序不在INSTALLED_APPS中,但其views.py正在运行 [英] django - app not in INSTALLED_APPS but its views.py is running
问题描述
python manage.py runserver --settings = myproj.settings_1.py
$ c $对于app1,c>
如果我运行
python manage.py runserver
它应该采用默认settings.py,我没有在 INSTALLED_APPS
,它应该给我错误的说,模块app1不存在,因为
#urls.py
urlpatterns = patterns('app1.views',#< ---- app1不在settings.py
url(r'^ $','startpage',name ='startpage '),
)
但是它将要 startpage
function inside app1.views
。
为什么会这样?我错过了什么吗?
没有理由不这样做。视图可以来自任何地方,而不必在一个应用程序中:他们只需要从Python路径访问。
I having multiple apps. I want to run them according to settings.py which means I have multiple settings_x.py. I run server e.g. like this:
python manage.py runserver --settings=myproj.settings_1.py
for app1.
If I run
python manage.py runserver
it should take the default settings.py where I didnot define any app in INSTALLED_APPS
, and It should give me error saying, that the module app1 doesnot exist because of
#urls.py
urlpatterns = patterns('app1.views',#<---- app1 isn't in the settings.py
url(r'^$', 'startpage', name='startpage'),
)
But it is going to startpage
function inside app1.views
.
why is this? am I missing something?
There's no reason why it wouldn't. Views can come from anywhere, and don't have to be in an app at all: they just need to be accessible from the Python path.
这篇关于django - 应用程序不在INSTALLED_APPS中,但其views.py正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!