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:

1
2
3
4
5
6
7
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
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.