Permissions in Django - Enforcing Permissions with permission_required()


Django tip:

To enforce permissions in function-based views, you can use the permission_required decorator 👇

from django.contrib.auth.decorators import permission_required

@permission_required("blog.view_post")
def post_list_view(request):
    return HttpResponse()

For more, check out Permissions in Django.