from django.shortcuts import render from django.http.response import HttpResponseNotAllowed from django.contrib.auth.decorators import permission_required from django.http import HttpResponse # Create your views here. def create_user(request): special_user = request.user if special_user.has_perm('abac.can_create_users'): pass #TODO: Create new User else: # Return a response indicating insufficient permissions return HttpResponseNotAllowed(request) @permission_required('abac.can_create_users', raise_exception=True) def create_user_view(request): # Your view logic here return HttpResponse('New user created')