title: Python decorator on instance method
body: <p>Anyone know what is wrong with this code?</p>
  
  <pre><code>def paginated_instance_method(default_page_size=25):
      def wrap(func):
          @functools.wraps(func)
          def inner(self, page=1, page_size=default_page_size, *args, **kwargs):
              objects = func(self=self, *args, **kwargs)
              return _paginate(objects, page, page_size)
          return inner
      return wrap
  
  class Event(object):
      ...
      @paginated_instance_method
      def get_attending_users(self, *args, **kwargs):
          return User.objects.filter(pk__in=self.attending_list)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>    Traceback (most recent call last):
        File "&lt;console&gt;", line 1, in &lt;module&gt;
        File "/Users/zarathustra/Virtual_Envs/hinge/hinge_services/hinge/api/decorators.py", line 108, in wrap
          def inner(self, page=1, page_size=default_page_size, *args, **kwargs):
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 33, in update_wrapper
          setattr(wrapper, attr, getattr(wrapped, attr))
      AttributeError: 'Event' object has no attribute '__name__'
  </code></pre>
  
  <p>The reason why I thought this would work is because, through trial and error, I got the following decorator working like a charm for classmethods:</p>
  
  <pre><code>def paginated_class_method(default_page_size=25):
      def wrap(func):
          @functools.wraps(func)
          def inner(cls, page=1, page_size=default_page_size, *args, **kwargs):
              objects = func(cls=cls, *args, **kwargs)
              return _paginate(objects, page, page_size)
          return inner
      return wrap
  </code></pre>