Python NameError: name 'include' is not defined [closed]

添加下面代码后:

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'',include('learning_blogs.urls', namespace = 'learning_blogs')),
]

有时候运行会出现如下错误:


Python NameError: name 'include' is not defined [closed]

 

 

可能是漏了添加模块,加入以下语句就好了:

from django.conf.urls import include

 

posted @ 2017-08-08 15:36  lqwh  阅读(669)  评论(0编辑  收藏  举报