Django配置url

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')

 

上一篇:学习笔记


下一篇:djangorestframework开发最完美手机购物商城APP带前后端源码