标签:.com att deb book strong 图片 imp 错误 技术分享
1、DEBUG模式:
2、视图函数:
1 #(app)front中views.py 2 from django.http import HttpResponse 3 4 def index(request): 5 return HttpResponse(‘网站首页‘) 6 7 def books(requeset,book_id): 8 text = ‘图书的ID是:%s‘ % book_id 9 return HttpResponse(text) 10 11 #项目urls.py 12 from django.urls import path 13 from front import views 14 15 urlpatterns = [ 16 #http://127.0.0.1:8000/ 17 path(‘‘,views.index), 18 #http://127.0.0.1:8000/book/1 19 path(‘book/<book_id>/‘,views.books) 20 ]
3、urls模块化:
1 #项目urls.py 2 --snip-- 3 urlpatterns = [ 4 path(‘book/‘,include(‘book.urls‘)) 5 ] 6 #book.urls为应用程序book的urls.py文件
1 #App的urls.py 2 --snip-- 3 urlpatterns = [ 4 path(‘/detail/<book_id>/‘,views.book_detail) 5 ]
后续更新...
标签:.com att deb book strong 图片 imp 错误 技术分享
原文地址:https://www.cnblogs.com/liqiongming/p/10289885.html