我正在使用Django
版本1.10。在django中集成html模板和url時出現錯誤
下面是我urls.py
(前端),
from django.conf.urls import include,url
from django.contrib import admin
urlpatterns = [
url(r'^webApp/', include('webApp.urls')),
url(r'^admin/', admin.site.urls),
url(r'^home/$', 'frontend.views.home', name='home'),
]
下面是我urls.py
(Web應用程序),
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
而下面是我的views.py
,
def home(request):
return render_to_response('home.html')
這裏,frontend
是我的項目名稱和webApp
是我的應用程序名稱。我在我的templates
文件夾中有home.html
frontend
。
當我運行,
python manage.py runserver 0.0.0.0:8000
我碰到下面的錯誤,
File "/root/frontend/frontend/urls.py", line 22, in <module>
url(r'^home/$', 'frontend.views.home', name='home'),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 85, in url
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include()
我不知道我做錯了...在同任何指導?
'webApp'包裏面有'urls.py'嗎? –
是的,我做...我試着評論和運行..給出了同樣的錯誤... – nidHi
在根'urls.py'中導入'webApp' –