Skip to content

Instantly share code, notes, and snippets.

@issackelly
Created July 11, 2011 00:12
Show Gist options
  • Save issackelly/1075119 to your computer and use it in GitHub Desktop.
Save issackelly/1075119 to your computer and use it in GitHub Desktop.
Show method_decorator on a Class Based View
from django.utils.decorators import method_decorator
from django.views.generic.base import TemplateView
from django.contrib.auth.decorators import login_required
class MaiView(TemplateView):
template_name = "mai/view.html"
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(MaiView, self).dispatch(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment