Created
July 21, 2012 17:28
-
-
Save danriti/3156492 to your computer and use it in GitHub Desktop.
Django - Restrict access to a view to only active and authenticated users
This file contains 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 user_passes_test, login_required | |
active_required = user_passes_test(lambda u: u.is_active, | |
login_url='/profile/not_active') | |
def active_and_login_required(view_func): | |
decorated_view_func = login_required(active_required(view_func)) | |
return decorated_view_func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment