Created
November 9, 2012 09:59
-
-
Save pstch/4044948 to your computer and use it in GitHub Desktop.
Django View that requires login when using site-wide login forms
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
| class ProtectedTemplateView(TemplateView): | |
| def dispatch(self, request, *args, **kwargs): | |
| if not request.user.is_authenticated(): | |
| print 'Potatoes !' | |
| return render(request, 'syncoor/auth/login_required.html', {'next' : request.get_full_path(), 'login_form_present' : True}) | |
| return super(ProtectedTemplateView, self).dispatch(request,*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment