1
00:00:00,210 --> 00:00:01,770
Hello and welcome back.

2
00:00:02,160 --> 00:00:08,010
In this session, I will discuss about that Class-Based view, that means before we knew any peace,

3
00:00:08,010 --> 00:00:09,840
we use it by the function.

4
00:00:10,110 --> 00:00:12,570
So now you can also view it by the class.

5
00:00:12,570 --> 00:00:14,120
So how can do that work?

6
00:00:14,130 --> 00:00:17,430
In this video, I will show you that things with the live example.

7
00:00:17,760 --> 00:00:22,650
So for doing this, I want to do I want to open our first project where I have already discussed about

8
00:00:22,650 --> 00:00:26,250
how to create one of the court application with using that my skill.

9
00:00:26,490 --> 00:00:26,840
Right.

10
00:00:27,060 --> 00:00:33,510
So now better able to do and open out this project, not this one I just knew file open and now go to

11
00:00:33,510 --> 00:00:37,440
our project up in the exercise file into the exercise file.

12
00:00:37,440 --> 00:00:39,480
I have created one of the court application.

13
00:00:39,480 --> 00:00:42,840
We now are Jianguo back this right into the general practice.

14
00:00:42,840 --> 00:00:45,000
So that is all my first project to know.

15
00:00:45,000 --> 00:00:48,840
I want to open it so just simply because I select a folder.

16
00:00:49,890 --> 00:00:54,950
So that is our Fuseproject, and here I have already discussed about that with you, how can create

17
00:00:54,960 --> 00:00:57,380
under the court application with using the database?

18
00:00:57,780 --> 00:00:59,480
So right now we don't need this.

19
00:00:59,490 --> 00:01:01,560
I just simply remove everything from here.

20
00:01:02,050 --> 00:01:07,400
OK, the simply problem with everything and also here, we don't need this.

21
00:01:08,070 --> 00:01:10,820
So that is our second project right now.

22
00:01:10,830 --> 00:01:12,680
I just simply remove our second project.

23
00:01:12,900 --> 00:01:16,160
So for the first project, I have also created one of the database.

24
00:01:16,170 --> 00:01:16,600
Right.

25
00:01:16,650 --> 00:01:22,590
So if you go to PSU admin, make sure, first of all, you have to run your apogee and the my skill.

26
00:01:23,220 --> 00:01:28,320
So I have already done my Apache and the my skill and for the reason I say can actually access our database.

27
00:01:28,330 --> 00:01:31,740
So I have already created one of the database as my first Jianguo.

28
00:01:32,070 --> 00:01:37,130
Now if you run our server like that is our project as a fast project.

29
00:01:37,980 --> 00:01:45,390
So in particular that folder, that was my first project and here I ran our Sarovar as a pie and that

30
00:01:45,390 --> 00:01:48,410
man is not pie and then run server.

31
00:01:49,740 --> 00:01:57,000
So now that is actually our you are to say to simply copy it and go to our side and here I just run

32
00:01:57,000 --> 00:01:57,240
it.

33
00:01:58,500 --> 00:02:02,940
So very consistent, I have already discussed about that things with you from here, if you want to

34
00:02:02,940 --> 00:02:05,400
add any musician, you can add it.

35
00:02:05,400 --> 00:02:08,750
If you want to add any album, then you can add any album.

36
00:02:09,030 --> 00:02:12,960
And that is our album, all the data if you want to edit it right.

37
00:02:12,960 --> 00:02:15,270
If you want to read this data, you can edit it.

38
00:02:15,540 --> 00:02:19,020
And also if you want to direct this data, you can direct it from here.

39
00:02:19,530 --> 00:02:24,570
So we have done everything with you, seeing that our function in our view, like right now, I want

40
00:02:24,570 --> 00:02:27,230
to add some of the musicians.

41
00:02:28,380 --> 00:02:33,630
I just simply defend that name as the be for this purpose.

42
00:02:33,630 --> 00:02:34,940
Actually, this data will be needed.

43
00:02:34,950 --> 00:02:38,860
So for now, I just add some of the musicians because they were musicians.

44
00:02:39,240 --> 00:02:46,740
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

45
00:02:46,800 --> 00:02:51,720
on the date and also defined as a good click at the album.

46
00:02:51,990 --> 00:02:52,890
Now go here.

47
00:02:52,890 --> 00:02:54,020
You can see album is added.

48
00:02:54,450 --> 00:02:58,410
We have already done everything and every data is comes from our database.

49
00:02:58,410 --> 00:03:02,880
That means here I have already created of the database if you go to that musician.

50
00:03:04,680 --> 00:03:09,330
And you can see that is actually the new data is perfectly inserted in our database area, so now we

51
00:03:09,330 --> 00:03:12,770
will do the same things, we will do the same things with using that.

52
00:03:12,770 --> 00:03:16,850
Plus, like if you go to The View piece right now, we don't need this.

53
00:03:17,100 --> 00:03:22,970
If you go to that view here, you can see I have declared all that our function that is our index function.

54
00:03:22,980 --> 00:03:28,260
And here I have created another function of the album list and also I have created another function

55
00:03:28,260 --> 00:03:29,320
as a musician form.

56
00:03:29,760 --> 00:03:33,900
So now we will do the same things with using that our Class-Based view.

57
00:03:33,940 --> 00:03:35,230
So how can do that work?

58
00:03:35,250 --> 00:03:35,880
I'll show you.

59
00:03:35,880 --> 00:03:42,960
Like I know I want to do everything because before I remove I want to do I want to save all the data.

60
00:03:42,970 --> 00:03:48,720
Then it will be helpful to, you know, go to our exercise file and that is our general practice.

61
00:03:48,760 --> 00:03:50,660
I simply copy them here.

62
00:03:50,670 --> 00:03:52,050
I take one of the folder.

63
00:03:52,890 --> 00:04:02,970
So that is actually our my just name it as a backup backup file and into the backup file here I want

64
00:04:02,970 --> 00:04:05,490
to do and to define better.

65
00:04:05,490 --> 00:04:07,130
I just simply copy it fast.

66
00:04:07,650 --> 00:04:09,590
So that is our general practice here.

67
00:04:09,630 --> 00:04:12,840
I have created on the court application simply the backup.

68
00:04:12,840 --> 00:04:19,010
Finally, I just simply passed it and I just wanted to change that name and here and name it as a code.

69
00:04:21,420 --> 00:04:26,760
OK, that means there is a global application, so just name it as a code application.

70
00:04:27,360 --> 00:04:31,310
OK, so if you need this file then you can actually access it from here.

71
00:04:31,890 --> 00:04:32,330
Perfect.

72
00:04:32,610 --> 00:04:38,340
So now I wanted to change it like here right now I don't need any data, so I want to remove everything.

73
00:04:38,610 --> 00:04:40,740
I want to make things from fresh.

74
00:04:41,250 --> 00:04:42,540
Also, I don't need this.

75
00:04:42,540 --> 00:04:44,400
I want to do and remove it.

76
00:04:45,300 --> 00:04:47,700
So first of all, I want to compare both of these.

77
00:04:47,700 --> 00:04:50,940
That means I want to compare our with our function and the class.

78
00:04:50,940 --> 00:04:54,000
Then it'll be easy to understand you for doing this.

79
00:04:54,000 --> 00:05:01,740
First of all, here, I want to want to take our EDP response like there is a Django and into the Django

80
00:05:01,740 --> 00:05:04,280
that it is TDP that you already know about it.

81
00:05:04,650 --> 00:05:09,750
So here from here, I want to import as it is TDP response.

82
00:05:11,100 --> 00:05:11,460
Right.

83
00:05:11,460 --> 00:05:13,620
So I just simply added diversity principles.

84
00:05:13,920 --> 00:05:19,390
So before what exactly would be before we have created one of the function as an index function.

85
00:05:19,420 --> 00:05:21,480
So first of all, I want to work with this.

86
00:05:21,480 --> 00:05:23,880
Then I will make that thing with the class.

87
00:05:23,880 --> 00:05:29,680
Then it will be very much clear to you, like here I define as a request, right?

88
00:05:29,730 --> 00:05:34,320
So that is our request and the function of the we I just simply defined as the return.

89
00:05:34,950 --> 00:05:38,160
And then SCDP is TDP response.

90
00:05:38,160 --> 00:05:43,380
And here we pass some of the extreme data like the Hello the World.

91
00:05:44,490 --> 00:05:44,910
Right.

92
00:05:46,110 --> 00:05:49,020
And also for this, we have defined one of that.

93
00:05:49,110 --> 00:05:54,120
You want to like if you go here into this position, that means in our main you are Sadiya.

94
00:05:54,120 --> 00:05:57,420
We have already created one of the mapping into the application.

95
00:05:57,420 --> 00:05:59,040
I also created another dewatered.

96
00:05:59,320 --> 00:06:02,060
So, you know, many Warrell here are defined as a pathway.

97
00:06:02,100 --> 00:06:05,670
It will be as a home, then it will be redirected to our Fastweb.

98
00:06:05,670 --> 00:06:06,540
You are right.

99
00:06:06,810 --> 00:06:11,100
That means you will be elected to our this first application in the first application.

100
00:06:11,100 --> 00:06:11,770
That is all you are.

101
00:06:12,300 --> 00:06:13,860
So right now here, I don't need this.

102
00:06:13,860 --> 00:06:17,840
I just simply remove everything because I want to make the things from fresh.

103
00:06:18,180 --> 00:06:22,620
So here I have already added our input part and the final step.

104
00:06:22,620 --> 00:06:28,890
I have added the views and I have created one of the app as the app name, and I just defined that app

105
00:06:28,890 --> 00:06:30,150
name as a fast app.

106
00:06:30,150 --> 00:06:30,450
Right.

107
00:06:30,660 --> 00:06:32,850
And then that is our usual pattern.

108
00:06:33,270 --> 00:06:36,150
So now I want to do I want to actually load out these functions.

109
00:06:36,160 --> 00:06:39,990
So if you want to loaded this function, I think you already know about it.

110
00:06:39,990 --> 00:06:45,990
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.

111
00:06:46,380 --> 00:06:49,110
So that is actually the way for our function view.

112
00:06:49,110 --> 00:06:50,640
So that is our function view.

113
00:06:50,640 --> 00:06:56,640
So if you want to visibly now, if you click to save all, I just click as to save all and now run our

114
00:06:56,640 --> 00:06:57,170
server.

115
00:06:57,810 --> 00:06:59,420
So Sara is now running.

116
00:06:59,430 --> 00:07:00,960
So now if you go to your home.

117
00:07:02,750 --> 00:07:05,510
Now you can is now returning as a hello world.

118
00:07:06,510 --> 00:07:10,940
So now, if you want to do the same things with the claspers view, how can do this work?

119
00:07:11,220 --> 00:07:16,770
So for doing this, we have to do we have to go through our view to the view so that in the view, that

120
00:07:16,770 --> 00:07:20,760
is actually our function of and I want to do an interview with the clouds, his view.

121
00:07:20,790 --> 00:07:26,130
So if you want to do that, well, first of all, here you have to do you have to add some of the class

122
00:07:26,580 --> 00:07:32,790
sizes and predefine of the farm and the Django sorry, into the jungle.

123
00:07:32,800 --> 00:07:41,370
They have also the views and the views that have all sort of the genetic, generic and the generic.

124
00:07:41,370 --> 00:07:42,590
Here we have to import.

125
00:07:42,840 --> 00:07:46,790
We have been put down one of the another class or the building class as a view.

126
00:07:47,130 --> 00:07:49,920
So I just simply added our this class as a view.

127
00:07:50,070 --> 00:07:53,870
And now I don't want to create another class, so I just name it as a class.

128
00:07:54,330 --> 00:07:59,610
And here I want to create the class name and I just name it as the index index view.

129
00:08:00,030 --> 00:08:02,090
This step of one of the class name I have defined.

130
00:08:02,100 --> 00:08:03,300
And now here we have to do.

131
00:08:03,300 --> 00:08:07,530
We have inherited our this class that we are building class.

132
00:08:07,530 --> 00:08:10,470
The views are just simply defend that view of a friend.

133
00:08:10,680 --> 00:08:15,420
And now into this class area we have to do we have to create one of the function so no one has to do

134
00:08:15,420 --> 00:08:19,920
and to create all the function as a dev and then the gate and here.

135
00:08:20,130 --> 00:08:24,930
And as I told you before, when you create any function into the class, then you have to define that

136
00:08:24,930 --> 00:08:26,010
things with the self.

137
00:08:26,010 --> 00:08:26,310
Right.

138
00:08:26,580 --> 00:08:30,330
So now I just simply defined as a self and then request.

139
00:08:31,230 --> 00:08:35,760
And then here I want to do and to pass on the return some of the text.

140
00:08:35,760 --> 00:08:40,200
So here I want to pass it with the study response and into the study response.

141
00:08:40,230 --> 00:08:44,460
Now I have to do and to show another message as a hello world.

142
00:08:45,930 --> 00:08:49,240
And that is and that is class based.

143
00:08:50,880 --> 00:08:52,590
OK, I understand that that is class.

144
00:08:52,590 --> 00:08:58,440
But so this testing, I want to pass it right now with our this class view so far, and I think you

145
00:08:58,440 --> 00:08:59,810
can well understand about it.

146
00:08:59,810 --> 00:09:05,490
So here I have the final of the class and I just named this class as an index view and the index view.

147
00:09:05,490 --> 00:09:08,150
I inherited our one of that building class.

148
00:09:08,150 --> 00:09:11,040
So we will be cast for our views and the generic.

149
00:09:11,280 --> 00:09:14,760
And from here I get our these building class as a view.

150
00:09:14,770 --> 00:09:16,410
So here I inherited it.

151
00:09:16,420 --> 00:09:22,020
OK, and after that, in this class area, I have to do I have to create one of the function and here

152
00:09:22,020 --> 00:09:25,290
I have to create the function as a gate and into this gate.

153
00:09:25,300 --> 00:09:30,180
As I told you, if you want to create any function into the class area, you have to pass one of the

154
00:09:30,180 --> 00:09:31,710
arguments to the self.

155
00:09:31,710 --> 00:09:32,100
Right.

156
00:09:32,310 --> 00:09:34,500
And then I just simply defined the request.

157
00:09:34,500 --> 00:09:36,270
And then I return our SCDP.

158
00:09:36,270 --> 00:09:37,790
One of the takes a hello world.

159
00:09:37,800 --> 00:09:38,970
That is the class based.

160
00:09:39,390 --> 00:09:41,670
So now we have to do we have to create one of that.

161
00:09:41,670 --> 00:09:42,870
You are for this one.

162
00:09:43,200 --> 00:09:48,500
But now if you want to create that, you are elenor our first application that you order and into the

163
00:09:48,510 --> 00:09:51,900
model area for the function we have defined as the views index.

164
00:09:51,900 --> 00:09:53,510
And I just name it as the index.

165
00:09:53,520 --> 00:09:53,790
Right.

166
00:09:53,820 --> 00:09:55,570
So before I have used that index.

167
00:09:55,570 --> 00:10:00,180
So now better I want to change it, then it shall be easy to understand you.

168
00:10:00,180 --> 00:10:01,440
I just name it as a test.

169
00:10:02,050 --> 00:10:07,140
OK, just name that function, name as a test to know what to do and to create another world for our

170
00:10:07,140 --> 00:10:07,940
claspers view.

171
00:10:07,950 --> 00:10:13,050
So if you want to display the class view you are old, then you have to do you have to define the views.

172
00:10:13,320 --> 00:10:16,500
And after this view we have to define your last name.

173
00:10:16,510 --> 00:10:20,970
So here I define the class name as index for you say just name it as the index view.

174
00:10:21,240 --> 00:10:27,310
And then after that, here you have to do you have to add your as under a score and that view.

175
00:10:27,870 --> 00:10:31,590
So here you have to add this as a as underscore view.

176
00:10:31,600 --> 00:10:34,890
OK, and then I just simply named this as an index.

177
00:10:34,890 --> 00:10:36,600
I just name it as the same name.

178
00:10:36,990 --> 00:10:38,180
So that is our part.

179
00:10:38,190 --> 00:10:40,040
So here I have defined that entity.

180
00:10:40,050 --> 00:10:43,350
That means there shall be our home popped right into the home.

181
00:10:43,350 --> 00:10:45,980
But I have defined that views in our index.

182
00:10:45,990 --> 00:10:48,240
That is the index view that is actually our class name.

183
00:10:48,240 --> 00:10:53,880
And here I define as as few as, which means it will be called our this class.

184
00:10:53,880 --> 00:10:55,620
That means this class as a view.

185
00:10:55,890 --> 00:10:58,770
So for the reasons here, you have to add that as a view.

186
00:10:58,770 --> 00:11:00,720
And then there is our name of the index.

187
00:11:00,900 --> 00:11:05,100
So that is the main basic difference between function and the class.

188
00:11:05,130 --> 00:11:12,210
So now if you run it like I just click and save all, so our server is now running and now if you refresh

189
00:11:12,210 --> 00:11:12,510
it.

190
00:11:13,260 --> 00:11:14,060
Yes.

191
00:11:14,070 --> 00:11:19,590
Now, considering now that is a lower class vis view and is now showing all this same data as a hello

192
00:11:19,590 --> 00:11:24,630
world, and that is that class space, I hope you get the little bit idea.

193
00:11:24,670 --> 00:11:28,430
What is the difference between our function based view and the clouds?

194
00:11:28,510 --> 00:11:28,950
His view.

195
00:11:28,950 --> 00:11:29,260
Right.

196
00:11:29,580 --> 00:11:35,040
So now if you want to add some of the templates before we have already defined s the template for our

197
00:11:35,040 --> 00:11:40,560
functions, if you want to add some of the template view into the clouds visible area, how can do that

198
00:11:40,560 --> 00:11:40,820
work?

199
00:11:40,830 --> 00:11:42,930
But I don't want to continue this process.

200
00:11:42,930 --> 00:11:45,920
In our next video, I will show that things with the live example.

201
00:11:46,500 --> 00:11:48,090
So thanks for watching.

202
00:11:48,090 --> 00:11:49,830
I will see you in the next video.
