Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15338 - Documented django.utils.decorators

  • Loading branch information...
commit d0345b71146ecb60af2277585b604fbc244d267b 1 parent d5a4f20
Tim Graham authored September 30, 2012

Showing 1 changed file with 31 additions and 0 deletions. Show diff stats Hide diff stats

  1. 31  docs/ref/utils.txt
31  docs/ref/utils.txt
@@ -170,6 +170,37 @@ The functions defined in this module share the following properties:
170 170
     ``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset`
171 171
     instance.
172 172
 
  173
+``django.utils.decorators``
  174
+===========================
  175
+
  176
+.. module:: django.utils.decorators
  177
+    :synopsis: Functions that help with creating decorators for views.
  178
+
  179
+.. function:: method_decorator(decorator)
  180
+
  181
+    Converts a function decorator into a method decorator. See :ref:`decorating
  182
+    class based views<decorating-class-based-views>` for example usage.
  183
+
  184
+.. function:: decorator_from_middleware(middleware_class)
  185
+
  186
+    Given a middleware class, returns a view decorator. This lets you use
  187
+    middleware functionality on a per-view basis. The middleware is created
  188
+    with no params passed.
  189
+
  190
+.. function:: decorator_from_middleware_with_args(middleware_class)
  191
+
  192
+    Like ``decorator_from_middleware``, but returns a function
  193
+    that accepts the arguments to be passed to the middleware_class.
  194
+    For example, the :func:`~django.views.decorators.cache.cache_page`
  195
+    decorator is created from the
  196
+    :class:`~django.middleware.cache.CacheMiddleware` like this::
  197
+
  198
+         cache_page = decorator_from_middleware_with_args(CacheMiddleware)
  199
+
  200
+         @cache_page(3600)
  201
+         def my_view(request):
  202
+             pass
  203
+
173 204
 ``django.utils.encoding``
174 205
 =========================
175 206
 

0 notes on commit d0345b7

Please sign in to comment.
Something went wrong with that request. Please try again.