Skip to content

Instantly share code, notes, and snippets.

@issackelly
Created August 30, 2011 15:07
Show Gist options
  • Save issackelly/1181113 to your computer and use it in GitHub Desktop.
Save issackelly/1181113 to your computer and use it in GitHub Desktop.
method_decorator around a Django Class Based View for login_required
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views.generic.base import TemplateView
import datetime
from accounts.forms import NewAccountForm
class DetailView(TemplateView):
"""
Lists accounts, and products that are accessible
to that account
"""
template_name = 'accounts/detail.html'
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(DetailView, self).dispatch( *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment