django-api-generator icon indicating copy to clipboard operation
django-api-generator copied to clipboard

Adding Response Headers

Open marqpdx opened this issue 3 years ago • 3 comments

I am wanting to use this with React Admin, which requires an 'X-Total-Count' response header. i was able to hard-code it (see below) but i am wondering if there are thoughts about having a config for additional resp. headers we might add?

Thanks!

            theData = [BookClubSerializer(instance=obj).data for obj in BookClub.objects.all()]
            resp = Response(theData, status=200)
            resp.headers['X-Total-Count'] = 2
            resp.headers['Access-Control-Expose-Headers'] = 'X-Total-Count'
            return resp

marqpdx avatar Nov 06 '22 22:11 marqpdx