Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #15338 - Documented django.utils.decorators

  • Loading branch information...
commit d0345b71146ecb60af2277585b604fbc244d267b 1 parent d5a4f20
@timgraham timgraham authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 docs/ref/utils.txt
View
31 docs/ref/utils.txt
@@ -170,6 +170,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``
=========================
Please sign in to comment.
Something went wrong with that request. Please try again.