Skip to content

Commit

Permalink
refs django#5797 Added documentation
Browse files Browse the repository at this point in the history
 about supporting multiple arguments on decorator_from_middleware
  • Loading branch information
hirokiky committed Jan 20, 2013
1 parent f74721f commit a9a1445
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/ref/utils.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,20 @@ The functions defined in this module share the following properties:
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)
.. function:: decorator_from_middleware(*middleware_classes)

Given a middleware class, returns a view decorator. This lets you use
.. versionchanged:: 1.6

Given a middleware classes, 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)
.. function:: decorator_from_middleware_with_args(*middleware_classes)

.. versionchanged:: 1.6

Like ``decorator_from_middleware``, but returns a function
that accepts the arguments to be passed to the middleware_class.
that accepts the arguments to be passed to the middleware_classes.
For example, the :func:`~django.views.decorators.cache.cache_page`
decorator is created from the ``CacheMiddleware`` like this::

Expand All @@ -198,6 +202,9 @@ The functions defined in this module share the following properties:
def my_view(request):
pass

When this function is called with multiple arguments, each middleware
takes same arguments.

``django.utils.encoding``
=========================

Expand Down
4 changes: 4 additions & 0 deletions docs/releases/1.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Minor features
undefined if the given ``QuerySet`` isn't ordered and there are more than
one ordered values to compare against.

* :func:`~django.utils.decorators.decorator_from_middleware` and
:func:`~django.utils.decorators.decorator_from_middleware_with_args` can take
multiple middleware classes.

Backwards incompatible changes in 1.6
=====================================

Expand Down

0 comments on commit a9a1445

Please sign in to comment.