I have an API developed in Django Rest Framework, from which I can expose some "public" data, clients that consume these services can obtain this information without the need to authenticate the user (session)
However I want anyone who consumes a service to pass a mandatory header attribute which contains a value that I can validate.
How can I validate from my APIView or viewsets that the requests received have said attribute and that it is valid
viewset:
class CiudadesViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
"""
Obtención del listado de ciudades
"""
queryset = models.Ciudad.objects.all()
serializer_class = serializers.CiudadSerializer
APIView:
class SolicitudesView(views.APIView):
def post(self, request):
...
return response