views.decorators.http.require_http_methods()

require_http_methods(request_method_list) [source]

Decorator to require that a view only accepts particular request methods. Usage:

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

Note that request methods should be in uppercase.

doc_Django
2016-10-09 18:40:46
Comments
Leave a Comment

Please login to continue.