一
test3/urls.py
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('booktest/', include('booktest.urls')), ]
booktest/urls.py
from django.conf.urls import url from booktest import views urlpatterns = [ url(r'^$', views.index), ]
booktest/views.py
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse('hello world')
二
test3/urls.py
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('booktest/', include('booktest.urls')), ]
booktest/urls.py
from django.conf.urls import url from booktest import views from django.urls import path urlpatterns = [ path('', views.index) ]
booktest/views.py
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse('hello world')
三
test3/urls.py
from django.contrib import admin from django.urls import path, include from booktest import views urlpatterns = [ path('admin/', admin.site.urls), path('booktest/', views.index), ]
booktest/views.py
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse('hello world')