Search code snippets, questions, articles... 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"
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

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

Was this helpful?
Join Devsheet Ask a Question