What this series is about
Unless things have drastically changed since I first learned Django a few years ago, most beginning tutorials are written using function-based views (FBVs). This is for good reason since FBVs are simple and easy to understand due to its procedural nature. You can see everything that is going on, and it's best to learn FBVs so that you know what's actually happening.
At some point you're going to read about this magical thing called Class-Based Views (CBVs) and begin to explore those. If you're reading this article, you've probably arrived at this phase! Congratulations, learning CBVs was probably the most important thing I have learned throughout the years of Django, and the most important decision I took.
Unlike FBVs, there is a lot of hidden code in CBVs, which is what makes it powerful as well as making it confusing at times. Instead of writing all the code, much of the code structure and actions are inferred, and it is up to you to learn what is expected.
What we're going to build
During this tutorial, we're going to take a blog project that is written in function-based views, and convert it to use class-based views. That alone could take just half an hour, but the problem most people have while learning CBV is that they don't understand how it works.
The problem most people have while learning CBV is that they don't understand how it works
When you just learn how to do it, when exceptions to the default come up, it gets very confusing. For that reason, we're going to learn what the hell is going on behind the scenes, because a lot of magic happens. That magic needs to be overridden sometimes, and we're going to learn how to handle those situations.
There are a set of generic class-based views which we're going to go over as well as learn about Mixins, Custom Mixins and django-braces which has some awesome community mixins.