What are views in Django?

In Django, a view is a class or function that accepts a request and responds with a response. A view is generally connected with URL patterns, and when a request to the URL associated with it is made, the logic wrapped in the view is executed. A view, among other things, uses models to retrieve data from the database, provides that data to the templates, and delivers the rendered template back to the user as a HttpResponse.

Python and Django follows MVT architecture in Web development hub.

M- Model(Where we define our database architecture)

V- Views (Where we write api or you can say write our logic)

T- Template( Django supports Full Stack development means you can write html code also in Django using Django template Language)

Using a function you can do following things:

  • Show a webpage with some information passed to it.
  • Submit some information to database.
  • Perform actions such as edit, delete, update.
  • You can also write function for any other actions.