1
00:00:05,280 --> 00:00:06,210
Welcome back everyone.

2
00:00:06,210 --> 00:00:10,950
We're going to continue where we left off last time by finishing up the user reviews and templates and

3
00:00:10,950 --> 00:00:14,310
we'll also test a little bit just to make sure everything is connected properly.

4
00:00:14,310 --> 00:00:15,360
Let's continue.

5
00:00:15,360 --> 00:00:15,570
All right.

6
00:00:15,570 --> 00:00:17,440
Here we are back where we left off.

7
00:00:17,490 --> 00:00:20,000
So far we've done the registration page.

8
00:00:20,010 --> 00:00:23,170
The log in page as well as the log out page.

9
00:00:23,250 --> 00:00:25,170
So we have those three components ready to go.

10
00:00:25,170 --> 00:00:29,640
Now what we want to focus on is the account page as well as setting up just the basic connection to

11
00:00:29,640 --> 00:00:31,330
the users list of blog posts.

12
00:00:31,350 --> 00:00:36,520
We haven't actually created any blog posts as far as anything beyond the models that pie.

13
00:00:36,630 --> 00:00:40,080
So we'll go ahead and kind of focus on more on the account and setting that up.

14
00:00:40,080 --> 00:00:42,840
So let's get started with that.

15
00:00:42,840 --> 00:00:47,490
So for the accounts page this really is kind of just there update the user forum page.

16
00:00:47,580 --> 00:00:54,950
We're going to do is two things we're going to say users route and we'll say forward slash accounts.

17
00:00:55,970 --> 00:01:00,260
And then we'll have those methods GO TO GET and POST

18
00:01:03,610 --> 00:01:07,360
and then we're also going to do is in order to actually see the account page you're going to have to

19
00:01:07,360 --> 00:01:10,180
be logged in because it's essentially an update form.

20
00:01:10,230 --> 00:01:13,120
We don't want someone to be able to update someone else's information.

21
00:01:13,360 --> 00:01:21,720
So we're going to have one more decorator here and have it be the log in required decorator and then

22
00:01:21,720 --> 00:01:26,410
we'll just call this view the account view and the form we're going to set up.

23
00:01:26,410 --> 00:01:30,280
Here is the update user form that we created a couple lectures ago.

24
00:01:30,530 --> 00:01:37,780
I will say if this form is validate on submit then we're going to do two things.

25
00:01:37,790 --> 00:01:40,640
Mainly we're going to be handling that picture upload.

26
00:01:40,640 --> 00:01:46,170
So if the form picture data colon.

27
00:01:46,300 --> 00:01:48,030
So this looks a little weird Salom explain it.

28
00:01:48,040 --> 00:01:51,230
We're going to see if they actually uploaded some picture data.

29
00:01:51,250 --> 00:01:53,090
So that's what this is statement's doing.

30
00:01:54,330 --> 00:02:02,370
Then we'll say that the user name is equal to the current user username and that the picture object

31
00:02:02,430 --> 00:02:11,720
is equal to add profile pic form picture data and then username.

32
00:02:11,720 --> 00:02:11,960
All right.

33
00:02:11,960 --> 00:02:15,830
So let's kind of break down what's happening here because with just these two lines of code we're actually

34
00:02:15,830 --> 00:02:16,610
doing a lot.

35
00:02:16,790 --> 00:02:20,290
Let's look back at what update user forum actually was.

36
00:02:20,350 --> 00:02:24,290
We come back to forms that pi and we go to our update user form.

37
00:02:24,320 --> 00:02:30,260
Remember we have this picture attribute which is a file field that allows someone to upload either a

38
00:02:30,500 --> 00:02:33,090
peg or a PMG file.

39
00:02:33,110 --> 00:02:39,480
So what's happening here is if they actually submitted something to that picture file field then this

40
00:02:39,520 --> 00:02:40,970
if statement gets activated.

41
00:02:40,980 --> 00:02:46,860
This essentially says yes there was some data in that picture attribute that all we're going to do is

42
00:02:46,860 --> 00:02:51,780
we're going to grab the current user's username and then we're going to say go ahead and add that profile

43
00:02:51,780 --> 00:02:57,900
pic essentially grab that actual data from the picture that Jay Pagar piano file and then grab their

44
00:02:57,950 --> 00:03:04,650
username and pass that into the ad profile pic function which if you remember we imported from picture

45
00:03:04,650 --> 00:03:06,830
handler that PI this file right here.

46
00:03:07,080 --> 00:03:12,220
And that's the function that we're using at pro profile pic with the picture upload and the username.

47
00:03:12,420 --> 00:03:18,570
And this automatically renames the file saves it for us and then saves it as also a thumbnail so it

48
00:03:18,570 --> 00:03:20,070
sets the size as well.

49
00:03:20,070 --> 00:03:21,990
So it does a lot of stuff for us.

50
00:03:21,990 --> 00:03:27,540
That's essentially what we're doing here in line 71 using that picture handler that PI file.

51
00:03:27,580 --> 00:03:34,010
Then once we've done all that we're going to grab the current user will do that by saying current user

52
00:03:34,100 --> 00:03:37,850
says Current User and we'll grab their profile image.

53
00:03:37,850 --> 00:03:44,090
So if you go back to models up high remember the actual user has a profile image attribute which is

54
00:03:44,090 --> 00:03:50,450
just the actual name or string of the static DNG file or JPEG file.

55
00:03:50,450 --> 00:03:57,170
So then we'll say profile image is now equal to pick which is what the ad profile pic returns for Comeback

56
00:03:57,200 --> 00:03:58,200
picture handler.

57
00:03:58,220 --> 00:04:01,040
Remember it's actually returning the storage file name.

58
00:04:01,040 --> 00:04:06,320
So that's essentially just a string that looks something like username TNG.

59
00:04:06,710 --> 00:04:13,860
So that is going to be the file path so we can then link here in views that pi to that profile image.

60
00:04:13,940 --> 00:04:18,880
So I'm going to delete that line right here of the comments and then come back to views that hi.

61
00:04:18,890 --> 00:04:25,090
So now we set the profile image for the user and let's finish the rest of the submission.

62
00:04:25,120 --> 00:04:27,970
So we'll see if foreigns valid submit we have the special thing.

63
00:04:27,970 --> 00:04:32,410
If there's actually picture data meaning if they actually upload a file everything else will just reset

64
00:04:32,410 --> 00:04:35,570
their user name and email in case they want to change those as well.

65
00:04:35,650 --> 00:04:43,840
We'll say current user their user name is equal to the form that username that data and then we'll say

66
00:04:43,840 --> 00:04:53,710
the current user e-mail is equal to form e-mail that data that will take our database session and we'll

67
00:04:53,710 --> 00:04:58,960
commit those changes and we can also flash the message if we want so we can say something like user

68
00:04:58,960 --> 00:05:01,750
account updated.

69
00:05:02,020 --> 00:05:06,400
So you can do that as well if you want to stay on the same page or alternatively you can just redirect

70
00:05:06,400 --> 00:05:11,480
them to something so I can say read direct you are l4.

71
00:05:11,610 --> 00:05:16,470
And in this case let's just go ahead and redirect them to their own account page so we can say something

72
00:05:16,470 --> 00:05:23,000
like users make sure that the string users thought account.

73
00:05:23,230 --> 00:05:25,250
And really it's up to you what you want to redirect.

74
00:05:25,270 --> 00:05:30,390
So essentially someone has gone to their account page and updated their form if you want to redirect

75
00:05:30,400 --> 00:05:32,140
to just like refresh the account page.

76
00:05:32,170 --> 00:05:36,070
That's fine you can just redirect here or maybe you want to redirect to the home page then you could

77
00:05:36,070 --> 00:05:42,430
just say redirect your four core index it's up to you what you would feel is more natural of a redirect

78
00:05:42,670 --> 00:05:45,490
upon updating the user form.

79
00:05:45,490 --> 00:05:50,450
Now we're also going to say the following here we're going to match in Elif to this statement.

80
00:05:50,440 --> 00:06:00,130
So say Elif if the request method is equal to get then what we're going to do here is say form thought

81
00:06:00,160 --> 00:06:10,210
username that data is equal to current user thought username and a form email that data is equal to

82
00:06:10,240 --> 00:06:12,720
current user.

83
00:06:12,900 --> 00:06:17,960
Email so that essentially says that they're not really submitting anything.

84
00:06:18,040 --> 00:06:22,730
Instead we're grabbing their current username and current e-mail information.

85
00:06:22,760 --> 00:06:27,250
Now the last thing I want to set up is the actual rendering of the template for their account page.

86
00:06:27,560 --> 00:06:29,210
So let's see what that's going to look like.

87
00:06:29,210 --> 00:06:41,990
We're going to say profile image is equal to your L4 we'll say static file name equal to profile underscore

88
00:06:41,990 --> 00:06:51,010
pick's forward slash word and concatenate that with the current user's profile image.

89
00:06:51,030 --> 00:06:56,600
So this is actually doing is it's going into the static folder underneath profile pics and then going

90
00:06:56,600 --> 00:06:58,890
to the current profile image that's there.

91
00:06:58,890 --> 00:07:02,570
So that's the default one unless they've been updated.

92
00:07:02,950 --> 00:07:10,080
So we'll see a return rendered template and we'll say a count but each T.M. and on the actual account

93
00:07:10,080 --> 00:07:12,840
page we're going to show the profile image for the user.

94
00:07:13,170 --> 00:07:18,780
So I'll say profile image is equal to profile image and then we're actually going to pass in that form

95
00:07:18,780 --> 00:07:21,210
as well will say form is equal to form.

96
00:07:21,300 --> 00:07:25,020
So that means we actually need to set up this account each team template.

97
00:07:25,170 --> 00:07:26,190
So let's go ahead and do that.

98
00:07:26,190 --> 00:07:31,200
Remember all we're doing here is we're giving them the option to update their information whether it's

99
00:07:31,200 --> 00:07:35,820
your username or email and we have some special functionality to make sure that they can upload the

100
00:07:35,820 --> 00:07:40,830
picture correctly because we have to check certain things like if it's a PMG or jpg file and then we

101
00:07:40,830 --> 00:07:46,110
also want to be able to grab that profile image and render it back into the account page.

102
00:07:46,140 --> 00:07:49,390
So with that being done let's set up the account that HTL template.

103
00:07:49,700 --> 00:07:56,160
So we'll come to this left hand tab underneath templates will create a new file and we'll call it account.

104
00:07:56,380 --> 00:08:02,450
T.M. and this is the count but a small template that's going to take in the profile image of the user

105
00:08:02,540 --> 00:08:04,570
as well as this update form.

106
00:08:04,580 --> 00:08:08,090
So let's set it up we'll come back to account that each team.

107
00:08:08,300 --> 00:08:11,260
And as always we want to make sure we extend from base HVM.

108
00:08:11,290 --> 00:08:17,990
So we get that navigation bar so we can set up our block the content block and then it's really up to

109
00:08:17,990 --> 00:08:19,990
you how you want to style this.

110
00:08:20,000 --> 00:08:24,920
I tend to like Jumbotron especially for simple things so I'll say Jumbotron then I'll create one more

111
00:08:24,920 --> 00:08:31,880
division here or another div here and all I'm going to see is just a line is equal to center and that

112
00:08:32,000 --> 00:08:35,910
makes the text and the image centered inside this Jumbotron.

113
00:08:35,910 --> 00:08:38,000
I mean I looked a little better when I was playing around this.

114
00:08:38,000 --> 00:08:45,730
So again a lot of the styling choices will be up to you will say welcome to the page for and then we'll

115
00:08:45,730 --> 00:08:55,080
grab the current user's username say user name here and then we'll we're going to do is put in their

116
00:08:55,620 --> 00:08:56,520
image.

117
00:08:56,580 --> 00:09:02,040
So the source for that is going to be the URL for.

118
00:09:02,430 --> 00:09:10,020
And then they'll be underneath the static folder the file name should be equal to profile underscore

119
00:09:10,020 --> 00:09:19,370
pick's forward slash and then concatenated with the current users the profile image.

120
00:09:19,430 --> 00:09:24,170
So we don't need an alternative we could alternative to a default but we don't worry about that because

121
00:09:24,170 --> 00:09:25,840
we set up that default already.

122
00:09:25,850 --> 00:09:32,080
So there's a source for the actual image and let's align that center as well just in case the images

123
00:09:32,090 --> 00:09:33,870
end up align Center.

124
00:09:33,930 --> 00:09:39,330
We can say align is to center here.

125
00:09:39,400 --> 00:09:39,620
All right.

126
00:09:39,630 --> 00:09:44,140
So let me zoom out or get ourselves just a little more room so we can see what's going on the full picture.

127
00:09:44,220 --> 00:09:46,900
Basically let's make sure we spot light correctly.

128
00:09:46,980 --> 00:09:50,770
Basically what we've done here is for this account page you get see.

129
00:09:50,790 --> 00:09:55,620
Welcome to the page for your username and then you get to see your profile image which is underneath

130
00:09:55,620 --> 00:09:58,460
the static folder underneath profile pics.

131
00:09:58,590 --> 00:10:02,320
The current user profile image may remember current user profile image.

132
00:10:02,340 --> 00:10:04,510
It's technically not a file.

133
00:10:04,620 --> 00:10:08,360
It's just the string of the actual location of that file.

134
00:10:08,370 --> 00:10:10,870
The next step is to set up our form.

135
00:10:10,920 --> 00:10:15,970
We're going to be passing in here I'll create a new division we'll just make this a container class.

136
00:10:15,990 --> 00:10:22,290
So it's centered and then we'll start our Form object for this we don't need a class or action.

137
00:10:22,290 --> 00:10:25,230
Instead all we're going to do is just give it the post method.

138
00:10:25,770 --> 00:10:34,260
And as you know I like to have post all caps then we'll begin inserting the actual form components first

139
00:10:34,260 --> 00:10:41,180
thing we're going to need is the hit and Ted So we have our form hit and tag and then we'll have the

140
00:10:41,180 --> 00:10:49,970
form user name label and attach to that is going to be the actual user name in there and we're going

141
00:10:49,970 --> 00:10:55,730
to do the same thing again except we'll do it for not just the name but for the e-mail and the picture

142
00:10:56,960 --> 00:11:00,180
so I get a copy and paste that some more times.

143
00:11:00,360 --> 00:11:04,270
So the next one that have user name it will be e-mail.

144
00:11:04,480 --> 00:11:07,550
And the next one here will also be e-mail.

145
00:11:07,630 --> 00:11:10,510
And then this one is going to be picture.

146
00:11:10,720 --> 00:11:17,500
So we will say picture and then this form is also going to be picture.

147
00:11:17,510 --> 00:11:20,210
And then finally we'll actually just say submit.

148
00:11:20,390 --> 00:11:27,380
So I can delete that one and save form dots and then say submit.

149
00:11:27,590 --> 00:11:31,880
Now I previously mentioned that we're not going to focus too much on styling but I do want to show you

150
00:11:31,880 --> 00:11:38,330
an example in case you are interested in adding in Bootstrap stylings specifically the form classes

151
00:11:38,720 --> 00:11:42,530
and the way you do that is if you check out the bootstrap documentation.

152
00:11:42,590 --> 00:11:46,850
So we bring that image here again or excuse me the browser.

153
00:11:46,850 --> 00:11:52,010
So remember if you come over to bootstrap home click on documentation and then click on components and

154
00:11:52,010 --> 00:11:57,170
you scroll down eventually you'll see forms and you'll see some examples here of forms.

155
00:11:57,440 --> 00:12:01,680
And basically what it is is you'll notice that bootstrap has a division.

156
00:12:01,730 --> 00:12:03,940
Let me zoom in so you can see it.

157
00:12:04,260 --> 00:12:07,070
It has the vision with a class called the form group.

158
00:12:07,190 --> 00:12:11,810
And essentially for each component such as this e-mail address component this password address component

159
00:12:11,870 --> 00:12:13,430
or this check me out component.

160
00:12:13,490 --> 00:12:18,710
These are all in their separate divisions with class form group and that allows some nice spacing between

161
00:12:18,710 --> 00:12:24,860
these inputs and the load as there is also classes such as form control or foreign text et cetera.

162
00:12:25,130 --> 00:12:30,350
What I'm going to do is I'm going to set up these divisions for form groups as well as adding in these

163
00:12:30,350 --> 00:12:32,080
classes like form control.

164
00:12:32,300 --> 00:12:34,560
So let me close this and then add that in.

165
00:12:34,640 --> 00:12:38,900
We won't do this for all the forms but I do want to show you an example of it in case you want to make

166
00:12:38,900 --> 00:12:41,230
your forms look a little nicer with bootstrap.

167
00:12:41,330 --> 00:12:48,250
So within our form tab I'm going to create a division and the class is going to be called form dash

168
00:12:48,260 --> 00:12:53,690
group and that's that form dash group class so we just saw in the bootstrap documentation and what I'm

169
00:12:53,700 --> 00:13:02,150
going to do is I'm going to put in each major component into its own form group.

170
00:13:02,210 --> 00:13:05,400
So let me copy and paste this a couple more times.

171
00:13:05,570 --> 00:13:08,760
So that's going to be for the e-mail label.

172
00:13:09,810 --> 00:13:15,980
This one's going to be for the picture and then we'll have one more for the actual submit button.

173
00:13:16,020 --> 00:13:19,940
And then won't want to close those divisions so let's do that as well.

174
00:13:20,460 --> 00:13:21,700
So we'll close these out.

175
00:13:24,070 --> 00:13:25,920
And we'll close this one out as well.

176
00:13:28,280 --> 00:13:29,270
And then we'll close.

177
00:13:29,270 --> 00:13:32,130
Finally the last one on the Submit button.

178
00:13:32,510 --> 00:13:33,080
OK.

179
00:13:33,080 --> 00:13:37,700
So now that we have everything in its own form group I'm actually going to want to make sure that the

180
00:13:37,700 --> 00:13:42,170
classes themselves for the labels are also in a form group.

181
00:13:42,170 --> 00:13:50,930
So the way we do that again is we just say label class is equal to form dash group and you can experiment

182
00:13:50,930 --> 00:13:55,270
with the class calls yourself in case you're interested in adding in some more bootstrap class calls.

183
00:13:55,370 --> 00:13:57,990
But I'm going to put this just for each label.

184
00:13:59,450 --> 00:14:05,690
And then what I'm also going to do is for the actual form component such as form user name all I'm going

185
00:14:05,690 --> 00:14:11,540
to do is set the class equal to form dash control.

186
00:14:11,540 --> 00:14:13,910
And if you're ever wondering what these class names are.

187
00:14:13,910 --> 00:14:15,480
Keep in mind I don't have these memorized.

188
00:14:15,500 --> 00:14:18,880
All I do is I reference the bootstrap documentation which is the same approach.

189
00:14:18,920 --> 00:14:24,250
You should be doing so going to copy and paste those class calls as well.

190
00:14:24,470 --> 00:14:28,590
And then finally for this form submit that's actually just a button.

191
00:14:28,700 --> 00:14:31,040
So I will set this equal to a button class.

192
00:14:31,040 --> 00:14:35,930
So after looking it up in the documentation I'll choose between between primary.

193
00:14:35,960 --> 00:14:40,310
So you can check out the button components to get these class names.

194
00:14:40,310 --> 00:14:46,100
All right so now when I see this on an actual Web site it should look a little nicer a little more formatted

195
00:14:46,130 --> 00:14:47,510
as bootstrap.

196
00:14:47,510 --> 00:14:49,370
So we will do that for the other forms.

197
00:14:49,370 --> 00:14:54,200
I just want to show you that you set up these divisions for each foreign component and then set up your

198
00:14:54,200 --> 00:14:56,090
class calls as you see fit.

199
00:14:56,500 --> 00:14:56,840
OK.

200
00:14:56,870 --> 00:14:57,930
So we'll save that.

201
00:14:57,950 --> 00:15:01,890
It looks like our form is looking good.

202
00:15:02,130 --> 00:15:07,850
If we go back to our views up-I file we just finished our account view.

203
00:15:07,860 --> 00:15:11,430
Now I want to finish off our user post view.

204
00:15:11,640 --> 00:15:17,140
So we're going to use the models for blog posts in order to make sure this works.

205
00:15:17,220 --> 00:15:23,790
So we'll come back here and say at users dot routes and we we're going to have here is this is going

206
00:15:23,790 --> 00:15:26,760
to be the route for the actual username.

207
00:15:27,150 --> 00:15:29,240
So we'll pass in a user name here.

208
00:15:29,370 --> 00:15:33,870
That is how I'm using these less than and greater than signs so the user name may change depending on

209
00:15:33,870 --> 00:15:34,840
the user.

210
00:15:35,020 --> 00:15:39,850
And then I will say T.F. and and zoom in here just a little bit so we can get a better idea.

211
00:15:39,870 --> 00:15:47,640
Let me add in some more lines to center this on the screen so I'll say DPF user posts and then that's

212
00:15:47,640 --> 00:15:49,590
going to take in the user name that's passed them.

213
00:15:49,740 --> 00:15:54,840
So basically before slash user number one user number two etc. basically whatever they are using it

214
00:15:54,840 --> 00:16:00,760
happens to be after this we're going to want to grab the actual blog post associated with that user.

215
00:16:00,870 --> 00:16:04,250
And we're also going to do is grab the page itself.

216
00:16:04,410 --> 00:16:06,360
So let me show you what I mean by that.

217
00:16:06,570 --> 00:16:15,650
I'm going to set a variable page and that's going to be called request dot Arc's gets.

218
00:16:16,170 --> 00:16:22,560
And I'm going to pasan page one type is equal to integer.

219
00:16:22,560 --> 00:16:29,960
And what this is going to allow us to later on do is cycle through user posts using pages.

220
00:16:29,970 --> 00:16:36,480
So that means if I have a user that has 150 blog posts I'm not going to see all 150 at a time.

221
00:16:36,480 --> 00:16:42,840
Instead we're going to use this right here of page equals along with some template work in order to

222
00:16:42,840 --> 00:16:45,400
actually make sure I can cycle through the pages.

223
00:16:45,480 --> 00:16:47,270
So we'll show you how to do that with bootstrap.

224
00:16:47,310 --> 00:16:52,100
But right now we'll just request it in this fashion and we'll kind of keep this in the back of our minds

225
00:16:52,140 --> 00:16:56,970
because this picture is not really going to be complete until we actually work on the template itself.

226
00:16:56,970 --> 00:17:03,740
So make sure you remember that this line exists because we're going to be referencing it later on then

227
00:17:03,740 --> 00:17:06,430
we just have two more lines and these are going to be a little more straightforward.

228
00:17:06,530 --> 00:17:10,380
Basically we're going to query for that user.

229
00:17:10,560 --> 00:17:16,360
So I'll say filter by where user name is equal to user name.

230
00:17:16,520 --> 00:17:22,700
So we're going to some user name page and we want to query for that username and there's a method that

231
00:17:22,700 --> 00:17:27,380
we can say first or for 0 4.

232
00:17:27,620 --> 00:17:32,810
So the reason for that is maybe someone decides to manually type out a user name but they typed out

233
00:17:32,810 --> 00:17:36,620
wrong instead of accidentally just getting some sort of major error.

234
00:17:36,620 --> 00:17:40,530
We can return a 404 page that says hey that user doesn't exist.

235
00:17:40,580 --> 00:17:45,950
So we're going to say either grab the first user since user names are unique or return for 0 for error

236
00:17:46,250 --> 00:17:48,380
meaning that page isn't found.

237
00:17:48,740 --> 00:17:52,220
Then once we have that user We're going to grab their blog posts.

238
00:17:52,790 --> 00:17:57,230
So we're going to grab from the blog post remember we created this in the models and we're going to

239
00:17:57,230 --> 00:18:02,480
query filter by author is equal to user.

240
00:18:02,510 --> 00:18:06,380
Remember the foreign key relationship that we created was called author.

241
00:18:06,380 --> 00:18:13,070
So if I go back to my models over here remember that I said the back reference was author for this user's

242
00:18:13,250 --> 00:18:13,860
posts.

243
00:18:13,910 --> 00:18:15,460
So that's what I'm calling here.

244
00:18:15,620 --> 00:18:19,320
Author is equal to user for that query on the blog post.

245
00:18:19,520 --> 00:18:25,460
So once I've done that I'm going to order these blog posts so I'll say filter by author.

246
00:18:25,550 --> 00:18:26,610
Equals to user.

247
00:18:26,960 --> 00:18:34,730
And then underscore or excuse me in order underscore by an I'm going to order them by their blog post

248
00:18:35,040 --> 00:18:39,750
dates and then I can call descending order.

249
00:18:40,270 --> 00:18:48,740
And then here this is where we're going to use that pages on a page in eight pages equal to page and

250
00:18:48,740 --> 00:18:50,410
then say per page.

251
00:18:51,860 --> 00:18:52,870
Is equal to five.

252
00:18:52,970 --> 00:18:58,060
So there's a lot going on here want to zoom out to make sure you kind of get the whole scope of everything.

253
00:18:58,230 --> 00:19:00,840
Basically we're requesting a particular page.

254
00:19:00,950 --> 00:19:06,140
So this allows us to actually cycle through the pages then we're grabbing whatever user there is or

255
00:19:06,140 --> 00:19:07,760
returning it for 0 4.

256
00:19:07,760 --> 00:19:13,910
Once we have that user We're going to query all our blog posts where the author happens to be equal

257
00:19:13,910 --> 00:19:15,170
to that particular user.

258
00:19:15,170 --> 00:19:19,370
And then we're going to order them by the date of that blog post in descending order.

259
00:19:19,370 --> 00:19:21,230
So a lot of this has to do with our.

260
00:19:21,470 --> 00:19:25,380
So specifically filter by an order by if you want to learn more about those.

261
00:19:25,520 --> 00:19:30,100
That's where you're really going to dive more into the sequel alchemy documentation and then that page

262
00:19:30,130 --> 00:19:35,330
and that actually allows us to have pages sorgen to say pages equal to the current page.

263
00:19:35,330 --> 00:19:37,210
So that's where this request comes from.

264
00:19:37,250 --> 00:19:39,650
And then per page you can edit this if you want.

265
00:19:39,650 --> 00:19:43,450
You can only show two blog posts per page or three blog posts per page.

266
00:19:43,460 --> 00:19:48,110
It's up to you you can play around with that value we're setting it to five per page.

267
00:19:48,110 --> 00:19:54,690
Then once we've done all that we're going to say return rendered template in word and create a template

268
00:19:54,690 --> 00:19:58,230
called Duzer underscore blog posts.

269
00:19:58,320 --> 00:20:06,800
H T.M. passen all the blog posts so I'll say blog post is equal to blog posts and then we'll also pasand

270
00:20:06,810 --> 00:20:09,450
the user so we can play around with that user information.

271
00:20:09,570 --> 00:20:14,550
So that means in the very next lecture we need to do is actually create this template so we have three

272
00:20:14,550 --> 00:20:15,420
lines of code here.

273
00:20:15,440 --> 00:20:16,810
But they're doing a ton of work.

274
00:20:16,830 --> 00:20:19,460
So let's make sure we truly understand what's going on here.

275
00:20:19,500 --> 00:20:23,750
When you go ahead and pasan a user name so you go to your website slashy username.

276
00:20:23,940 --> 00:20:25,470
We're going to pass in that username.

277
00:20:25,650 --> 00:20:30,690
We're going to grab whatever page you're currently on so this page right here that's connected to the

278
00:20:30,690 --> 00:20:35,200
page call here for showing it a certain number of blog posts per page.

279
00:20:35,340 --> 00:20:38,850
Then we're going to actually query for that user.

280
00:20:38,930 --> 00:20:41,560
So grab the user or attorney 404 error.

281
00:20:41,640 --> 00:20:46,820
Once you have that user we filter the blog posts based off where the author matches that user.

282
00:20:46,890 --> 00:20:52,290
Then we order by the blog post state in descending order and then paginate based off how many block

283
00:20:52,320 --> 00:20:56,710
those who want to show per page and then we're going to render this in our template user blog post.

284
00:20:56,730 --> 00:21:01,320
H t m l where we plant passen that list of block blog posts so later on we'll be using a little bit

285
00:21:01,320 --> 00:21:05,690
template logically for posts and blog posts and then abusing the user there.

286
00:21:05,880 --> 00:21:11,150
OK so up next we want to do is really hone down on this user blog post each T.M..

287
00:21:11,310 --> 00:21:16,170
This is probably the most complex view we've done so far and it's quite different than other views because

288
00:21:16,170 --> 00:21:20,130
we haven't really seen something like this in the course yet so take your time with this one and make

289
00:21:20,130 --> 00:21:24,530
sure you kind of copy and paste from the notes really well because lots potentials for typos here.

290
00:21:24,870 --> 00:21:25,260
OK.

291
00:21:25,470 --> 00:21:28,750
Coming up next we're going to develop this template for the user blog posts.

292
00:21:28,770 --> 00:21:29,440
We'll see if.
