标签:nbsp ati col IV port 定制 sel dispatch self
django的 CBV
定制dispatch,定制响应头,定制cookie
1 from django.shortcuts import render,HttpResponse 2 from django.views import View 3 # Create your views here. 4 class Myindex(View): 5 #定制dispatch 6 def dispatch(self, request, *args, **kwargs): 7 result=super(Myindex,self).dispatch(request,*args,**kwargs) 8 return result 9 def get(self,request): 10 return render(request,‘index.html‘) 11 def post(self,request): 12 #定制响应头 13 ret=HttpResponse(‘saoka‘) 14 ret[‘h1‘]=‘v1‘ 15 ret[‘h2‘]=‘v3‘ 16 #设置cookie 17 ret.set_cookie(‘c1‘,‘v2‘) 18 ret.set_cookie(‘c2‘,‘v3‘) 19 return ret
django的 静态文件路径的设置
STATICFILES_DIRS=[
os.path.join(BASE_DIR,‘static‘)
]
标签:nbsp ati col IV port 定制 sel dispatch self
原文地址:https://www.cnblogs.com/hexintong/p/9135799.html