summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2012-09-30 13:37:25 -0400
committerTim Graham <timograham@gmail.com>2012-09-30 13:42:38 -0400
commitcf482d6e2a322a8c84570ae282b774fa09491c98 (patch)
treec58c63b2ab0b65417e2590056268494fa9c2d352
parent4dba4ed548c0abdf4cdc0f3781d1c4d89a567d23 (diff)
[1.4.X] Fixed #15338 - Documented django.utils.decorators
Backport of d0345b7114 from master
-rw-r--r--docs/ref/utils.txt31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index cd79976265..dd86b3a7b1 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -166,6 +166,37 @@ The functions defined in this module share the following properties:
``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset`
instance.
+``django.utils.decorators``
+===========================
+
+.. module:: django.utils.decorators
+ :synopsis: Functions that help with creating decorators for views.
+
+.. function:: method_decorator(decorator)
+
+ Converts a function decorator into a method decorator. See :ref:`decorating
+ class based views<decorating-class-based-views>` for example usage.
+
+.. function:: decorator_from_middleware(middleware_class)
+
+ Given a middleware class, returns a view decorator. This lets you use
+ middleware functionality on a per-view basis. The middleware is created
+ with no params passed.
+
+.. function:: decorator_from_middleware_with_args(middleware_class)
+
+ Like ``decorator_from_middleware``, but returns a function
+ that accepts the arguments to be passed to the middleware_class.
+ For example, the :func:`~django.views.decorators.cache.cache_page`
+ decorator is created from the
+ :class:`~django.middleware.cache.CacheMiddleware` like this::
+
+ cache_page = decorator_from_middleware_with_args(CacheMiddleware)
+
+ @cache_page(3600)
+ def my_view(request):
+ pass
+
``django.utils.encoding``
=========================