From 4dfc6ff8a81ed36dfc7c5b942ecab7217866b935 Mon Sep 17 00:00:00 2001 From: Ben Lomax Date: Fri, 8 Jul 2022 09:39:33 +0100 Subject: Refs #31949 -- Made @never_cache and @cache_control() decorators to work with async functions. Thanks Carlton Gibson and Mariusz Felisiak for reviews. --- docs/releases/5.0.txt | 4 +++- docs/topics/async.txt | 25 +++++++++++++++++++++++++ docs/topics/http/decorators.txt | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index 3a4355588b..48df713375 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -214,7 +214,9 @@ CSRF Decorators ~~~~~~~~~~ -* ... +* The :func:`~django.views.decorators.cache.cache_control` and + :func:`~django.views.decorators.cache.never_cache` decorators now support + wrapping asynchronous view functions. Email ~~~~~ diff --git a/docs/topics/async.txt b/docs/topics/async.txt index 4b667f22a1..769fac3c52 100644 --- a/docs/topics/async.txt +++ b/docs/topics/async.txt @@ -73,6 +73,31 @@ from an async view, you will trigger Django's :ref:`asynchronous safety protection ` to protect your data from corruption. +Decorators +---------- + +.. versionadded:: 5.0 + +The following decorators can be used with both synchronous and asynchronous +view functions: + +* :func:`~django.views.decorators.cache.cache_control` +* :func:`~django.views.decorators.cache.never_cache` + +For example:: + + from django.views.decorators.cache import never_cache + + + @never_cache + def my_sync_view(request): + ... + + + @never_cache + async def my_async_view(request): + ... + Queries & the ORM ----------------- diff --git a/docs/topics/http/decorators.txt b/docs/topics/http/decorators.txt index 3481eefb3c..4bcae64e27 100644 --- a/docs/topics/http/decorators.txt +++ b/docs/topics/http/decorators.txt @@ -117,6 +117,10 @@ client-side caching. :func:`~django.utils.cache.patch_cache_control` for the details of the transformation. + .. versionchanged:: 5.0 + + Support for wrapping asynchronous view functions was added. + .. function:: never_cache(view_func) This decorator adds an ``Expires`` header to the current date/time. @@ -127,6 +131,10 @@ client-side caching. Each header is only added if it isn't already set. + .. versionchanged:: 5.0 + + Support for wrapping asynchronous view functions was added. + .. module:: django.views.decorators.common Common -- cgit v1.2.1