django: return string from view

According to the documentation:

A view function, or view for short, is simply a Python function that
takes a Web request and returns a Web response.

Each view function is responsible for returning an HttpResponse
object.

In other words, your view should return a HttpResponse instance:

from django.http import HttpResponse

def myview(request):
    return HttpResponse("return this string")

Leave a Comment