Fixed #15338 - Documented django.utils.decorators

This commit is contained in:
Tim Graham 2012-09-30 13:37:25 -04:00
parent d5a4f209c3
commit d0345b7114
1 changed files with 31 additions and 0 deletions

View File

@ -170,6 +170,37 @@ The functions defined in this module share the following properties:
``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset` ``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset`
instance. 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`` ``django.utils.encoding``
========================= =========================