Created
August 30, 2011 15:07
-
-
Save issackelly/1181113 to your computer and use it in GitHub Desktop.
method_decorator around a Django Class Based View for login_required
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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