1.项目 url
from django.contrib import admin from django.conf.urls import url from django.urls import include
urlpatterns = [url('admin/', admin.site.urls),url(r'', include('book.urls')), ]
2.book APP的url
from django.contrib import admin from django.conf.urls import url from book import views from django.urls import includeurlpatterns = [url('admin/', admin.site.urls),# url(r'^index$', include('book.urls')),url('index', views.index), #和视图函数做请求url('create', views.create), #和视图函数做请求url('addAjax', views.addAjax), #和视图函数做请求url('getAll', views.getAll), #和视图函数做请求url(r'^delete(\d+)$', views.dele), #和视图函数做请求 ]
3.出错就在项目url(r'^index$', include('book.urls')),用这导致路径请求不到,,而需要用 url(r'', include('book.urls')),