Created
December 3, 2014 12:04
-
-
Save andreyshuster/0b99ef2b30779fd01649 to your computer and use it in GitHub Desktop.
user_passes_test class based
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
# http://stackoverflow.com/questions/8082670/django-user-passes-test-decorator | |
class SuperuserRequiredMixin(object): | |
@method_decorator(user_passes_test(lambda u: u.is_superuser)) | |
def dispatch(self, *args, **kwargs): | |
return super(SuperuserRequiredMixin, self).dispatch(*args, **kwargs) | |
class MyView(SuperuserRequiredMixin, View): | |
def get(self, request): | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment