【Django进阶】
Django路由映射FBV 和 CBV
django中请求处理方式有2种:FBV(function base views) 和 CBV(class base views),换言之就是一种用函数处理请求,一种用类处理请求。
FBV
# url.py from django.conf.urls import url, include from mytest import views urlpatterns = [ url(r‘^index/‘, views.index), ] # views.py from django.shortcuts import render def index(req): if req.method == ‘POST‘: print(‘method is :‘ + req.method) elif req.method == ‘GET‘: print(‘method is :‘ + req.method) return render(req, ‘index.html‘)