Python django中的url.py
问题是,django项目中的URL.py文件如下所示:Python django中的url.py,python,django,Python,Django,问题是,django项目中的URL.py文件如下所示: urlpatterns = patterns('', ... url(r'^admin/', include(admin.site.urls)), url(r'^testapp/', include('testapp.urls')), #Here is the problem. ) 我安装了一个名为“testapp”的应用程序,所以我在模式中编写了include('testapp.url') 问题是,我为什么要把
urlpatterns = patterns('',
...
url(r'^admin/', include(admin.site.urls)),
url(r'^testapp/', include('testapp.urls')), #Here is the problem.
)
我安装了一个名为“testapp”的应用程序,所以我在模式中编写了include('testapp.url')
问题是,我为什么要把testapp.url
放在引号中?
因为我试着这样说:url('r^testapp/',include(testapp.url))
,它不起作用。
为什么?您必须在URL.py中导入应用程序
import testapp
urlpatterns = patterns('',
...
url(r'^admin/', include(admin.site.urls)),
url(r'^testapp/', include(testapp.urls)),
)
您必须在URL.py中导入应用程序
import testapp
urlpatterns = patterns('',
...
url(r'^admin/', include(admin.site.urls)),
url(r'^testapp/', include(testapp.urls)),
)
ad3w已经回答了您的问题。如果您想了解更多信息,请查看以下内容:ad3w已经回答了您的问题。如果您想了解更多信息,请查看以下内容: