django-Views之装饰器四

1.选择支持的请求方式

from django.views.decorators.http import require_http_methods
from django.shortcuts  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()

 

相关文章

注:所有源代码均实测运行过。所有源代码均已上传CSDN,请有...
继承APIView和ViewSetMixin;作用也与APIView基本类似,提供...
一、Django介绍Python下有许多款不同的 Web 框架。Django是重...
本文从nginx快速掌握到使用,gunicorn快速掌握到使用,实现小...
uniapp微信小程序订阅消息发送服务通知
Django终端打印SQL语句 1 Setting配置: 2 默认python 使用的...