View decorators —
can be used to restrict access to views based on the request method.
View decorators —
Can be used to control caching behavior on particular views.
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