Django Class Based Views

From Django 1.3, The concept of class based views has come up. In this way, view functions are replaced by Python objects.
Specific HTTP methods can be determined by separate methods and can be used more like object-based techniques (mixins).

Class Based Views

First, let’s see the difference between the function and method in Python with an example.:

Let’s run the method:

Function

Execute function:

Output;

output
output

For an HTTP GET on Django , a view function looks like this:

While in CBV (class-based views) :

Urls.PY

Get and post methods in CBV:
On a CBV, the arguments of the Get and POST method are self, request (HttpRequest), and the request argument you specify in Urlconfig.:

Source;

https://docs.djangoproject.com/en/dev/topics/class-based-views/intro/
http://lgiordani.github.io/blog/2013/10/28/digging-up-django-class-based-views-1/
http://programmer.97things.oreilly.com/wiki/index.php/Don’t_Repeat_Yourself

https://bonosindeposito.io/