TypeError: view must be a callable or a list/tuple in the case of include().
网址
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^$',"newhomaa.views.home", name='home'),
url(r'^admin/', include(admin.site.urls)),
视图
from django.shortcuts import render
def home(request):
return render(request,"home.html",{})
INSTALLED_APPS
= [
'newhomaa',
我需要解决我的问题
答案 0 :(得分:1)
从您的视图中导入home
函数,并在您的网址格式中使用该函数而不是字符串。
from newhomaa.views import home
urlpatterns = [
url(r'^$', home, name='home'),
url(r'^admin/', admin.site.urls),
]
请注意,在Django 1.9+中,您不需要将include()
与admin.site.urls
一起使用。