In Django, what is a view?

In Django, what is a view?

a) A database table
b) A function or class that handles a web request and returns a web response
c) A template that defines the layout of a page
d) A middleware function

Answer:

b) A function or class that handles a web request and returns a web response

Explanation:

A Django view is a Python function or class that takes a web request and returns a web response, which can be an HTML page, a JSON object, or any other response type.

Reference:

Django Quiz – MCQ Questions and Answers

Scroll to Top