Chrome Extension

Allow or limit a view to superuser only Django

from django.contrib.auth.decorators import user_passes_test

@user_passes_test(lambda u: u.is_superuser)
def score_reset(request):
    return "View"
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now

Use this code to limit a view to superuser only. We use Django auth decorator 'user_passes_test' to implement it.

Was this helpful?
Open Code Manager We are hiring