16.8. API Permissions
>>>
... from django.views.generic import View
... from django.http import JsonResponse
... from django.contrib.auth.mixins import PermissionRequiredMixin
... from shop.models import Customer
...
...
... class ContactJSON(PermissionRequiredMixin, View):
... permission_required = 'contact.can_view'
...
... def get(self, request, **kwargs):
... p = Customer.objects.all().values()
... return JsonResponse(status=HTTPStatus.OK, data=list(p), safe=False)