A view function or view in short is like a Python function that a Web request and returns Web response.This response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML document, or an image . . . or anything, really.
When we created our polls app a views.py file was created in polls directory, we gonna write all our views here.
Write your first view
Open the file polls/views.py and put the following Python code in it: