DEV Community

Abby Nduta
Abby Nduta

Posted on

Function-based views in Django: Simple version

When starting a Django project, we should create views and map them to URLs. Easy and straightforward, but why is it all confusing?

Let’s try to break it down.

There are two types of views that you can create in Django: function based views and class based views.

I'll focus on function-based views here.

Function based views have two types of responses: a simple HTTP Response, or they can render a template.

The following view returns an HTTPResponse:

Image description

The second view renders a template, which is the about us page, about.html:

Image description

Top comments (0)