zoukankan      html  css  js  c++  java
  • django视图装饰器——Allowed HTTP methods

    Allowed HTTP methods
      这些装饰器在django.views.decorators.http中,可以用来限制对视图的访问方式。如果不是规定的方式,那么将返回一个django.http.HttpResponseNotAllowed。

    from django.views.decorators.http import require_http_methods

    @require_http_methods(["GET", "POST"])
    def my_view(request):
     # I can assume now that only GET or POST requests make it this far
     # ...
     pass

    还有require_GET()、require_POST()方法,分别只限于使用GET或者POST方法访问。

  • 相关阅读:
    第九章:switch语句
    第八章:if-else语句
    第七章:运算符及运用
    第六章:名命规范
    事务
    jdbc
    Object
    容器
    Java exception
    Java OO1
  • 原文地址:https://www.cnblogs.com/chenjianhong/p/4145093.html
Copyright © 2011-2022 走看看