Hi, I just added a patch to this ticket. It includes 2 solutions:
First one is an implementation of Luke's idea with a class attribute. You just define an sequence: class MyView(View): decorators = [login_required, never_cache] # MyView.as_view === login_required(never_cache(View.as_view)) The `as_view` method then applies the decorators to the closure before returning it. This works nice with subclassing and isn't very magic. The important thing to note, is that all decorators are applied before the login enters dispatch(), so this is different then applying decorators to dispatch(). Second one, introduces a class decorator that decorates the as_view() method. This can be altered to use method_decorator() to decorate dispatch() instead, but during the whole process I decided that decorating as_view() works better (or maybe my brain turned into a cloud of steam from all this decoration). This approach has some serious pitfall, I wasn't aware of before: Subclassing in a decorator + super() in Python 2.x = trouble. See [1] and [2] for example of how to shot yourself in the foot with it. Thus, the decorator modifies the class it was given. I added a "subclass" argument, so you can write: MyView = view_decorator(login_required, subclass=True)(TemplateView) but it looks kinda clumsy. Comments here or directly on my github branch[3] very appreciated. Sorry, for another long email and thanks for reading it. [1]: http://github.com/lqc/django/commit/9b32817e00cdfa82568c45506e4c5b17cec68748#L0R53 [2]: http://gist.github.com/643536 [3]: http://github.com/lqc/django/commits/cbvdecoration_ticket14512 Best regards, Łukasz Rekucki -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.