Skip to content

Commit

Permalink
Fixed #15328 -- Corrected an example in the CBV docs and added a note…
Browse files Browse the repository at this point in the history
… about the parameters passed by method_deorator to the method on the class. Thanks to airstrike for the report and lrekucki for the correction.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15563 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
Gabriel Hurley committed Feb 18, 2011
1 parent fe11100 commit e06dfda
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/topics/class-based-views.txt
Expand Up @@ -605,8 +605,15 @@ that it can be used on an instance method. For example::
template_name = 'secret.html'

@method_decorator(login_required)
def dispatch(self, **kwargs):
def dispatch(self, *args, **kwargs):
return super(ProtectedView, self).dispatch(**kwargs)

In this example, every instance of :class:`ProtectedView` will have
In this example, every instance of ``ProtectedView`` will have
login protection.

.. note::

``method_decorator`` passes ``*args`` and ``**kwargs``
as parameters to the decorated method on the class. If your method
does not accept a compatible set of parameters it will raise a
``TypeError`` exception.

0 comments on commit e06dfda

Please sign in to comment.