28_django限制请求方法装饰器
Django限制请求方法 常见的请求有: GET/POST GET:GET请求一般用来向服务器索取数据,但不会向服务器提交数据,不会对服务器的状态进行更改 POST: POST请求一般是用来向服务器提交数据,会对服务器的状态进行更改 在Django中 限制请求方法的装饰器 Django 内置的视图装饰器可以给视图提供一些限制。比如这个视图只能通过 GET 的 method 访问 等。 from django.views.decorators.http import require_POST, require_http_methods, require_GET 1. reruire_http_methods from django.http.decorators.http import require_http_methods @require_http_methods(['GET']) # require_http_methods(['GET', 'POST']) def img_captcha(request, img_uuid): """ 生成图片验证码 url: /img_captcha/ :param request: :return: """ pass 2. require_GET @require_GET def check_username(request,