Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.4.X] Fixed #15338 - Documented django.utils.decorators

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

0 notes on commit cf482d6

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