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)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay