零、项目搭建
0.1 路由分发
- 
全局路由 urls.pyfrom django.urls import path, include urlpatterns = [ # 1、路由分发 path('', include('app01.urls')), path('app01/', include('app01.urls')), path('app02/', include('app02.urls')), ]
- 
局部路由 app01/urls.pyfrom django.urls import path from app01 import views urlpatterns = [ # 2、路由分发 path('login/', views.login), path('reg/', views.reg), ]
0.2 视图函数
- 
app01/views.pyfrom django.shortcuts import render, redirect, HttpResponse # 3、视图函数 def login(request): pass # 4、模版 return render(request, "login.html", locals()) def reg(request): pass return render(request, "reg.html", locals())
0.3 模版templates
- templates/login.html
- templates/reg.html
0.4 静态文件static
- 
settings.pySTATIC_URL = '/static/' # 静态文件路径 STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ]
 
     
    
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号