Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thisboyiscrazy/5091345 to your computer and use it in GitHub Desktop.
Save thisboyiscrazy/5091345 to your computer and use it in GitHub Desktop.
A TemplateView mixed with a Login Required view
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView
class LoginRequiredMixin(object):
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(LoginRequiredMixin, self).dispatch(*args, **kwargs)
class LoginRequiredTemplateView(LoginRequiredMixin,TemplateView):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment