Hello and welcome back.
In this session, I will discuss about that Class-Based view, that means before we knew any peace,
we use it by the function.
So now you can also view it by the class.
So how can do that work?
In this video, I will show you that things with the live example.
So for doing this, I want to do I want to open our first project where I have already discussed about
how to create one of the court application with using that my skill.
Right.
So now better able to do and open out this project, not this one I just knew file open and now go to
our project up in the exercise file into the exercise file.
I have created one of the court application.
We now are Jianguo back this right into the general practice.
So that is all my first project to know.
I want to open it so just simply because I select a folder.
So that is our Fuseproject, and here I have already discussed about that with you, how can create
under the court application with using the database?
So right now we don't need this.
I just simply remove everything from here.
OK, the simply problem with everything and also here, we don't need this.
So that is our second project right now.
I just simply remove our second project.
So for the first project, I have also created one of the database.
Right.
So if you go to PSU admin, make sure, first of all, you have to run your apogee and the my skill.
So I have already done my Apache and the my skill and for the reason I say can actually access our database.
So I have already created one of the database as my first Jianguo.
Now if you run our server like that is our project as a fast project.
So in particular that folder, that was my first project and here I ran our Sarovar as a pie and that
man is not pie and then run server.
So now that is actually our you are to say to simply copy it and go to our side and here I just run
it.
So very consistent, I have already discussed about that things with you from here, if you want to
add any musician, you can add it.
If you want to add any album, then you can add any album.
And that is our album, all the data if you want to edit it right.
If you want to read this data, you can edit it.
And also if you want to direct this data, you can direct it from here.
So we have done everything with you, seeing that our function in our view, like right now, I want
to add some of the musicians.
I just simply defend that name as the be for this purpose.
Actually, this data will be needed.
So for now, I just add some of the musicians because they were musicians.
So here, if you want to add some of the album as a B and they name it as A and then I just defined
on the date and also defined as a good click at the album.
Now go here.
You can see album is added.
We have already done everything and every data is comes from our database.
That means here I have already created of the database if you go to that musician.
And you can see that is actually the new data is perfectly inserted in our database area, so now we
will do the same things, we will do the same things with using that.
Plus, like if you go to The View piece right now, we don't need this.
If you go to that view here, you can see I have declared all that our function that is our index function.
And here I have created another function of the album list and also I have created another function
as a musician form.
So now we will do the same things with using that our Class-Based view.
So how can do that work?
I'll show you.
Like I know I want to do everything because before I remove I want to do I want to save all the data.
Then it will be helpful to, you know, go to our exercise file and that is our general practice.
I simply copy them here.
I take one of the folder.
So that is actually our my just name it as a backup backup file and into the backup file here I want
to do and to define better.
I just simply copy it fast.
So that is our general practice here.
I have created on the court application simply the backup.
Finally, I just simply passed it and I just wanted to change that name and here and name it as a code.
OK, that means there is a global application, so just name it as a code application.
OK, so if you need this file then you can actually access it from here.
Perfect.
So now I wanted to change it like here right now I don't need any data, so I want to remove everything.
I want to make things from fresh.
Also, I don't need this.
I want to do and remove it.
So first of all, I want to compare both of these.
That means I want to compare our with our function and the class.
Then it'll be easy to understand you for doing this.
First of all, here, I want to want to take our EDP response like there is a Django and into the Django
that it is TDP that you already know about it.
So here from here, I want to import as it is TDP response.
Right.
So I just simply added diversity principles.
So before what exactly would be before we have created one of the function as an index function.
So first of all, I want to work with this.
Then I will make that thing with the class.
Then it will be very much clear to you, like here I define as a request, right?
So that is our request and the function of the we I just simply defined as the return.
And then SCDP is TDP response.
And here we pass some of the extreme data like the Hello the World.
Right.
And also for this, we have defined one of that.
You want to like if you go here into this position, that means in our main you are Sadiya.
We have already created one of the mapping into the application.
I also created another dewatered.
So, you know, many Warrell here are defined as a pathway.
It will be as a home, then it will be redirected to our Fastweb.
You are right.
That means you will be elected to our this first application in the first application.
That is all you are.
So right now here, I don't need this.
I just simply remove everything because I want to make the things from fresh.
So here I have already added our input part and the final step.
I have added the views and I have created one of the app as the app name, and I just defined that app
name as a fast app.
Right.
And then that is our usual pattern.
So now I want to do I want to actually load out these functions.
So if you want to loaded this function, I think you already know about it.
You have to define as a part and then view I we have defined as an index and I just name it as the index.
So that is actually the way for our function view.
So that is our function view.
So if you want to visibly now, if you click to save all, I just click as to save all and now run our
server.
So Sara is now running.
So now if you go to your home.
Now you can is now returning as a hello world.
So now, if you want to do the same things with the claspers view, how can do this work?
So for doing this, we have to do we have to go through our view to the view so that in the view, that
is actually our function of and I want to do an interview with the clouds, his view.
So if you want to do that, well, first of all, here you have to do you have to add some of the class
sizes and predefine of the farm and the Django sorry, into the jungle.
They have also the views and the views that have all sort of the genetic, generic and the generic.
Here we have to import.
We have been put down one of the another class or the building class as a view.
So I just simply added our this class as a view.
And now I don't want to create another class, so I just name it as a class.
And here I want to create the class name and I just name it as the index index view.
This step of one of the class name I have defined.
And now here we have to do.
We have inherited our this class that we are building class.
The views are just simply defend that view of a friend.
And now into this class area we have to do we have to create one of the function so no one has to do
and to create all the function as a dev and then the gate and here.
And as I told you before, when you create any function into the class, then you have to define that
things with the self.
Right.
So now I just simply defined as a self and then request.
And then here I want to do and to pass on the return some of the text.
So here I want to pass it with the study response and into the study response.
Now I have to do and to show another message as a hello world.
And that is and that is class based.
OK, I understand that that is class.
But so this testing, I want to pass it right now with our this class view so far, and I think you
can well understand about it.
So here I have the final of the class and I just named this class as an index view and the index view.
I inherited our one of that building class.
So we will be cast for our views and the generic.
And from here I get our these building class as a view.
So here I inherited it.
OK, and after that, in this class area, I have to do I have to create one of the function and here
I have to create the function as a gate and into this gate.
As I told you, if you want to create any function into the class area, you have to pass one of the
arguments to the self.
Right.
And then I just simply defined the request.
And then I return our SCDP.
One of the takes a hello world.
That is the class based.
So now we have to do we have to create one of that.
You are for this one.
But now if you want to create that, you are elenor our first application that you order and into the
model area for the function we have defined as the views index.
And I just name it as the index.
Right.
So before I have used that index.
So now better I want to change it, then it shall be easy to understand you.
I just name it as a test.
OK, just name that function, name as a test to know what to do and to create another world for our
claspers view.
So if you want to display the class view you are old, then you have to do you have to define the views.
And after this view we have to define your last name.
So here I define the class name as index for you say just name it as the index view.
And then after that, here you have to do you have to add your as under a score and that view.
So here you have to add this as a as underscore view.
OK, and then I just simply named this as an index.
I just name it as the same name.
So that is our part.
So here I have defined that entity.
That means there shall be our home popped right into the home.
But I have defined that views in our index.
That is the index view that is actually our class name.
And here I define as as few as, which means it will be called our this class.
That means this class as a view.
So for the reasons here, you have to add that as a view.
And then there is our name of the index.
So that is the main basic difference between function and the class.
So now if you run it like I just click and save all, so our server is now running and now if you refresh
it.
Yes.
Now, considering now that is a lower class vis view and is now showing all this same data as a hello
world, and that is that class space, I hope you get the little bit idea.
What is the difference between our function based view and the clouds?
His view.
Right.
So now if you want to add some of the templates before we have already defined s the template for our
functions, if you want to add some of the template view into the clouds visible area, how can do that
work?
But I don't want to continue this process.
In our next video, I will show that things with the live example.
So thanks for watching.
I will see you in the next video.