<commit_before>===============
View decorators
===============

.. module:: django.views.decorators.http

Django provides several decorators that can be applied to views to support
various HTTP features.

Allowed HTTP methods
====================

The decorators in :mod:`django.views.decorators.http` can be used to restrict
access to views based on the request method. These decorators will return
a :class:`django.http.HttpResponseNotAllowed` if the conditions are not met.

.. function:: require_http_methods(request_method_list)

    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.

.. function:: require_GET()

    Decorator to require that a view only accepts the GET method.

.. function:: require_POST()

    Decorator to require that a view only accepts the POST method.

.. function:: require_safe()

    Decorator to require that a view only accepts the GET and HEAD methods.
    These methods are commonly considered "safe" because they should not have
    the significance of taking an action other than retrieving the requested
    resource.

    .. note::
        Django will automatically strip the content of responses to HEAD
        requests while leaving the headers unchanged, so you may handle HEAD
        requests exactly like GET requests in your views. Since some software,
        such as link checkers, rely on HEAD requests, you might prefer
        using ``require_safe`` instead of ``require_GET``.

Conditional view processing
===========================

The following decorators in :mod:`django.views.decorators.http` can be used to<commit_msg>Refs #26052 -- Corrected a sentence for conditional_content_removal() removal.<commit_after>===============
View decorators
===============

.. module:: django.views.decorators.http

Django provides several decorators that can be applied to views to support
various HTTP features.

Allowed HTTP methods
====================

The decorators in :mod:`django.views.decorators.http` can be used to restrict
access to views based on the request method. These decorators will return
a :class:`django.http.HttpResponseNotAllowed` if the conditions are not met.

.. function:: require_http_methods(request_method_list)

    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.

.. function:: require_GET()

    Decorator to require that a view only accepts the GET method.

.. function:: require_POST()

    Decorator to require that a view only accepts the POST method.

.. function:: require_safe()

    Decorator to require that a view only accepts the GET and HEAD methods.
    These methods are commonly considered "safe" because they should not have
    the significance of taking an action other than retrieving the requested
    resource.

    .. note::
        Web servers should automatically strip the content of responses to HEAD
        requests while leaving the headers unchanged, so you may handle HEAD
        requests exactly like GET requests in your views. Since some software,
        such as link checkers, rely on HEAD requests, you might prefer
        using ``require_safe`` instead of ``require_GET``.

Conditional view processing
===========================

The following decorators in :mod:`django.views.decorators.http` can be used to
{'fraction_non_alphanumeric': 0.0943683409436834, 'fraction_numerical': 0.0012683916793505834, 'mean_word_length': 3.5062857142857142, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6791670', 'n_tokens_mistral': 966, 'n_tokens_neox': 920, 'n_words': 451}