django-Views之装饰器(四)

前端之家收集整理的这篇文章主要介绍了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()

 

猜你在找的Django相关文章