django.conf.urls.defaults
在 Django 1.4 中已弃用,后来在 Django 1.6 中删除。读这个。而且您使用的包urls
与 Django 1.9 不兼容。根据 Django 1.9文档,您应该定义urls.py
为,
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^articles/2003/$', views.special_case_2003),
url(r'^articles/([0-9]{4})/$', views.year_archive),
url(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),
url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),
]
更新:
您可以修改urls.py
如下以使其正常工作,
from django.conf.urls import url, include
from ajax_search import views as as_views
ajax_search_urlpatterns = [
url(r'^xhr_search$','as_views.xhr_search'),
url(r'^search/', 'as_views.search'),
]
urlpatterns = [
url(r'^ajax_search/',include(ajax_search_urlpatterns)),
]