django-Views之装饰器(四)
1.选择支持的请求方式 from django.views.decorators.http import require_http_methods from django.shortcuts import render @require_http_methods(['GET','POST']) def index(request): return render(request,"search.html") 2.只允许GET方法 require_GET() 3.只允许POST方法 require_POST() 4.只允许get和head方法 require_safe() 来源: https://www.cnblogs.com/xiximayou/p/11743237.html