Maryam
Maryam

Reputation: 73

Removing additional double quotes in django rest response

I'm new to Django rest framework, I tried to create a view

class TestView(APIView):

    def get(self, request, *args, **kwargs):
        return Response("Hello world")

When I send a request with curl or request module in python like this:

curl -X GET localhost:8000/test/

I get "Hello world" as a response, what I actually need is Hello world string without the additional double-quotes. I tried different content_types, but none of them worked so far. How can I get rid of the double-quotes?

Upvotes: 3

Views: 1517

Answers (1)

Mattia
Mattia

Reputation: 1129

As Iain says, use HttpResponse instead of Response

from django.http import HttpResponse

class TestView(APIView):
    def get(self, request, *args, **kwargs):
        return HttpResponse("Hello world")

Upvotes: 4

Related Questions