O'Reilly logo

Learning Django Web Development by Ratan Kumar, Sanjeev Jaiswal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to class-based views

Class-based views are the new way of defining views in Django. They do not replace function-based views. They are just an alternative way to implement views as Python objects instead of functions. There are two advantages they have over function-based views. With a class-based view, different HTTP requests can be mapped to a different function, as opposed to a function-based view where the branching takes place based on the request.method parameter. Object-oriented techniques can be used to reuse the code component, such as mixins (multiple inheritance).

Although we will be using class-based views for our project, to understand the exact difference between the two, here we will present the code for both.

We will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required