+1 vote
in Data Handling by
Give an example of a Django view.

1 Answer

0 votes
by

A view in Django either returns an HttpResponse or raises an exception such as Http404. HttpResponse contains the objects that consist of the content that is to be rendered to the user.

EXAMPLE:

from django.http import HttpResponse

def hello_world(request):

    html = "

<h1>Hello World!</h1>

"

    return HttpResponse(html)

Related questions

+1 vote
asked Apr 4, 2020 in Data Handling by amita rallin
+1 vote
asked Apr 4, 2020 in Data Handling by amita rallin
...