1
00:00:05,120 --> 00:00:06,190
Welcome back, everyone.

2
00:00:06,200 --> 00:00:12,380
In this lecture, we're going to focus on a user specific page, almost like a user profile page that

3
00:00:12,380 --> 00:00:18,920
only logged in user should be able to view their own specific profile, basically giving them authentication

4
00:00:19,130 --> 00:00:21,230
and ownership over a single page.

5
00:00:21,650 --> 00:00:28,040
To do this, we're going to add in some new attributes to one of our book instance classes or models.

6
00:00:28,130 --> 00:00:34,010
That way, we can actually associate a book instance to a specific user, essentially checking out a

7
00:00:34,010 --> 00:00:34,910
book, so to speak.

8
00:00:35,330 --> 00:00:37,070
Let's do this inside our code.

9
00:00:37,610 --> 00:00:43,910
All right, here I am, back inside our code editor in order to actually connect a book instance to

10
00:00:43,940 --> 00:00:44,630
a user.

11
00:00:44,660 --> 00:00:47,060
What I need to do is edit my models a little bit.

12
00:00:47,510 --> 00:00:50,600
So recall if I go to models that pie and scroll down.

13
00:00:50,810 --> 00:00:55,370
I have the book and then I have if I scroll down a book instance.

14
00:00:55,760 --> 00:01:01,250
Remember, the book instance is a unique book that is a actual physical copy.

15
00:01:01,610 --> 00:01:06,680
So it's not just something like Catcher in the Rye, it's actually copy number one of Catcher in the

16
00:01:06,680 --> 00:01:06,920
Rye.

17
00:01:06,920 --> 00:01:09,350
And there can be copy number two of Catcher in the Rye, etc..

18
00:01:09,740 --> 00:01:15,410
So what would be nice is if I could associate a book instance to a specific user, especially if it's

19
00:01:15,410 --> 00:01:16,940
checked out, then it makes sense.

20
00:01:17,090 --> 00:01:18,230
So let's actually do this.

21
00:01:18,800 --> 00:01:24,050
I'm going to add in a new class attribute called, let's say, borrower.

22
00:01:25,190 --> 00:01:28,160
So bar is going to be equal to models dot.

23
00:01:28,340 --> 00:01:33,410
And then we have to decide, is this a foreign key or is this something like a many to many relationship?

24
00:01:33,890 --> 00:01:38,810
Well, if you think about it, a single book instance should only have a single borrower.

25
00:01:39,110 --> 00:01:44,690
So this is more akin to a foreign key relationship because it's a one, two, one, really, a physical

26
00:01:44,690 --> 00:01:48,860
copy of a book should only be able to be borrowed by one particular user.

27
00:01:48,950 --> 00:01:51,740
So we're going to say foreign key relationship.

28
00:01:52,910 --> 00:01:56,840
Now, the other thing to point out here is that how do we actually connect this to a user?

29
00:01:57,260 --> 00:02:01,870
Well, we already know, based off our previous discussions and exploration of documentation, that

30
00:02:01,880 --> 00:02:03,860
I can actually just import the user model.

31
00:02:04,370 --> 00:02:13,760
So basically, in any that profile inside of Django, I can say from Django dot contrib dot off the

32
00:02:13,760 --> 00:02:18,410
model's import user and that gives me access to the user model.

33
00:02:18,490 --> 00:02:23,660
Notice it's not being used yet, so I need a scroll down here and pass it in as a foreign key relationship

34
00:02:24,890 --> 00:02:27,570
that I have to decide what happens if you delete this.

35
00:02:27,620 --> 00:02:28,100
So.

36
00:02:29,430 --> 00:02:33,840
If I were to delete this particular user, then I was going to set it to NULL.

37
00:02:34,780 --> 00:02:35,860
So I'll say sitting on.

38
00:02:36,800 --> 00:02:39,110
And that means I need to say null is equal to true.

39
00:02:39,110 --> 00:02:40,700
So it can't actually be Noel.

40
00:02:41,000 --> 00:02:45,560
And we should also be able to leave this blank in case nobody has ever checked out this particular instance

41
00:02:45,560 --> 00:02:46,010
of the book.

42
00:02:46,760 --> 00:02:51,260
Now, remember, whenever you start updating your models that profile, you need to run migrations.

43
00:02:51,680 --> 00:02:56,120
So that means I'm going to essentially kill what I have going on here.

44
00:02:58,160 --> 00:02:59,630
And then we're going to say.

45
00:03:00,660 --> 00:03:01,380
Python.

46
00:03:02,400 --> 00:03:03,940
Let me clear this up.

47
00:03:03,960 --> 00:03:04,770
So, Python.

48
00:03:05,940 --> 00:03:07,140
Manage that pie.

49
00:03:08,920 --> 00:03:10,420
Make migrations.

50
00:03:11,880 --> 00:03:16,020
So we can see I added field borrower for the book instance and let's say Python.

51
00:03:17,000 --> 00:03:19,260
Manage that pie migrate.

52
00:03:19,970 --> 00:03:21,950
Okay, so it looks like everything worked well there.

53
00:03:22,220 --> 00:03:27,080
If you got an error, you're going to want to check back and make sure you wrote this borrower line

54
00:03:27,080 --> 00:03:27,770
correctly.

55
00:03:28,070 --> 00:03:32,360
Essentially links a user as a foreign key to a specific book instance.

56
00:03:32,630 --> 00:03:39,170
So now we should be able to do is visit her admin page and actually connect a particular book instance

57
00:03:39,170 --> 00:03:39,740
to a user.

58
00:03:40,190 --> 00:03:45,950
Eventually you would build out pages to make this all form based, so the user would go fill out a form

59
00:03:45,950 --> 00:03:52,670
in this particular instance, etc. maybe a dropdown list, maybe a list view for all the book instances,

60
00:03:52,670 --> 00:03:53,780
etc., using queries.

61
00:03:53,780 --> 00:03:58,010
But right now we're going to do this the admin, so we don't make like a thousand pages here.

62
00:03:58,850 --> 00:04:00,530
So we say Python manage that pie.

63
00:04:01,830 --> 00:04:02,610
Run server.

64
00:04:03,990 --> 00:04:06,000
And now our website is running.

65
00:04:06,210 --> 00:04:06,450
All right.

66
00:04:06,450 --> 00:04:08,400
So let me bring in our home page.

67
00:04:08,490 --> 00:04:12,810
Something to note is you should be logged out before visiting the admin right now.

68
00:04:13,200 --> 00:04:17,880
Basically, the admin is working with the user authentication system.

69
00:04:18,180 --> 00:04:22,560
So if you visit the admin page but you're logged in, you'll get a warning from Django saying you're

70
00:04:22,560 --> 00:04:24,150
already authenticated as another user.

71
00:04:24,420 --> 00:04:26,010
Would you like to log in as someone else?

72
00:04:26,040 --> 00:04:27,990
So let's go to forward slash admin here.

73
00:04:28,380 --> 00:04:29,700
It's time to log in.

74
00:04:30,030 --> 00:04:32,970
You have to use the credentials based off the super user you created.

75
00:04:33,390 --> 00:04:37,200
I think I created one called my admin, so let me fill out those credentials.

76
00:04:37,530 --> 00:04:40,200
If you forget this, you can always create another superuser at the command line.

77
00:04:40,830 --> 00:04:41,710
And here we go.

78
00:04:41,730 --> 00:04:45,300
So now I see authors, book instances, books, genres, languages.

79
00:04:45,630 --> 00:04:46,800
I also see users.

80
00:04:47,220 --> 00:04:53,940
So if we take a look at users, for example, I have the super users admin and my admin, and then I

81
00:04:53,940 --> 00:04:55,420
also have my user and my user too.

82
00:04:55,890 --> 00:05:01,330
Let's go with my user here and then they have the password active, etc..

83
00:05:02,130 --> 00:05:04,560
User Permissions Important Dates.

84
00:05:04,560 --> 00:05:06,300
Last Login Date Join.

85
00:05:06,630 --> 00:05:11,480
But you notice right now I actually want to connect this user to a book instance.

86
00:05:11,490 --> 00:05:16,400
So then I could come to book instances and I only have one book in my library.

87
00:05:16,410 --> 00:05:18,570
So if you want you could add more instances.

88
00:05:18,930 --> 00:05:23,910
But I have an instance here of super mystery, so let me click on this one and I'm going to select that

89
00:05:24,090 --> 00:05:26,100
my user has borrowed it.

90
00:05:26,490 --> 00:05:30,720
So now I could say, okay, it's on loan, so let's go ahead and save this.

91
00:05:32,380 --> 00:05:38,500
So you'll notice right now that this particular book instance, essentially the only book inside our

92
00:05:38,500 --> 00:05:41,110
library here, is being borrowed by my user.

93
00:05:41,500 --> 00:05:47,980
So what I want to do is set up a page where my user can log in and then actually see the books that

94
00:05:47,980 --> 00:05:48,850
they've checked out.

95
00:05:49,360 --> 00:05:51,550
So that's all we need to do in the Django Admin page.

96
00:05:52,000 --> 00:05:58,150
Obviously you could do this using forms and selecting model forms, etc. and have it be done on a page,

97
00:05:58,150 --> 00:05:59,650
which is eventually what you want to create.

98
00:05:59,980 --> 00:06:02,980
But for right now, we'll save those steps and just do it through the admin console.

99
00:06:03,730 --> 00:06:07,090
I have faith in you that by the time you've reached this part of the course, you know how to do that

100
00:06:07,090 --> 00:06:09,460
sort of thing, connecting models and making views for them.

101
00:06:10,030 --> 00:06:14,110
So I'm just going to simply say, log out here and I've been logged out.

102
00:06:14,650 --> 00:06:18,070
Click here to log in and I'm going to log in as my user.

103
00:06:19,190 --> 00:06:20,240
My password.

104
00:06:20,390 --> 00:06:21,530
I think it was one, two, three.

105
00:06:21,530 --> 00:06:21,860
Here.

106
00:06:22,250 --> 00:06:22,700
Perfect.

107
00:06:22,970 --> 00:06:24,470
So now I'm logged in as my user.

108
00:06:24,560 --> 00:06:29,870
What I want to do now is set up a template and view for actually doing a query and seeing, well, what

109
00:06:29,870 --> 00:06:30,890
books do you have checked out?

110
00:06:31,160 --> 00:06:33,830
So that's the final part of this little exercise here.

111
00:06:34,400 --> 00:06:35,630
So I'm going to come back here.

112
00:06:36,470 --> 00:06:39,230
And then let's go ahead and set that up.

113
00:06:39,740 --> 00:06:43,670
So what I want to do is set up a template and also set up a view.

114
00:06:44,540 --> 00:06:49,730
There's lots different ways we could do this, but it probably makes sense to use a generic list view

115
00:06:49,940 --> 00:06:56,390
where I just run a query of book instances and actually filter them based off the user.

116
00:06:56,630 --> 00:06:58,350
So there's different ways you could do this.

117
00:06:58,370 --> 00:07:01,970
You could do a query based off the user and grab their books.

118
00:07:01,970 --> 00:07:05,690
But I think it actually makes more sense to take advantage of the list view.

119
00:07:06,200 --> 00:07:09,530
That way you can actually do it from a book instance perspective.

120
00:07:09,920 --> 00:07:14,360
So that will actually make our life a little simpler as far as defining the view.

121
00:07:14,390 --> 00:07:20,270
So we're to come back to views mixture at the top where you have create view and detail view that you

122
00:07:20,270 --> 00:07:22,010
import list view.

123
00:07:23,600 --> 00:07:25,370
So let's create this view.

124
00:07:25,760 --> 00:07:28,520
And remember, I've also imported the log and required mixing.

125
00:07:29,480 --> 00:07:31,370
So someone should have to be logged in to view this.

126
00:07:31,640 --> 00:07:33,020
So we're gonna do the following, I'm going to say.

127
00:07:33,970 --> 00:07:34,540
Class.

128
00:07:35,700 --> 00:07:43,290
And we'll say checked out books, let's say, by user view.

129
00:07:43,530 --> 00:07:45,330
So kind of a long name here.

130
00:07:45,630 --> 00:07:46,770
You don't need to do it this long.

131
00:07:47,730 --> 00:07:48,840
The login is required.

132
00:07:49,910 --> 00:07:52,550
And I'm also going to inherit from list of you.

133
00:07:54,420 --> 00:07:54,720
Okay.

134
00:07:55,080 --> 00:07:57,570
So that means someone needs to be logged in to view this page.

135
00:07:57,690 --> 00:07:58,800
That's exactly what I want.

136
00:07:58,810 --> 00:08:00,090
I don't want to show them something else.

137
00:08:00,090 --> 00:08:04,190
I just want to redirect them to the login page if they happen to check for their checked out books.

138
00:08:04,200 --> 00:08:09,990
And I also want to make sure it's a list view, wireless view, because the point here is in general,

139
00:08:10,350 --> 00:08:17,190
I'm just going to list all book instances, but I will filter.

140
00:08:18,150 --> 00:08:20,490
Based off currently.

141
00:08:21,690 --> 00:08:23,160
Logged in user session.

142
00:08:26,180 --> 00:08:27,110
So how do I do this?

143
00:08:27,140 --> 00:08:30,980
Well, I first thing to connect it to a model which already know is my book instance model.

144
00:08:31,400 --> 00:08:32,990
So we have to make sure we imported that.

145
00:08:32,990 --> 00:08:34,309
So come all the way to the top.

146
00:08:34,669 --> 00:08:38,090
You'll notice from the models I have book instance imported here.

147
00:08:38,090 --> 00:08:39,289
So that looks like it's good to go.

148
00:08:39,890 --> 00:08:41,179
So I connected it to the model.

149
00:08:41,690 --> 00:08:45,630
Then I need to connect it to the template name that I'll eventually create for this.

150
00:08:45,650 --> 00:08:51,290
So we'll say catalog forward slash and let's actually just call this profile for each HTML.

151
00:08:51,800 --> 00:08:53,540
We can decide on a better name for it later on.

152
00:08:54,590 --> 00:09:00,350
And then if you want, depending on how many books you've created, you can also use page eight.

153
00:09:00,950 --> 00:09:06,980
By what page rate means is how many pages or how many instances do you want to show per page?

154
00:09:07,490 --> 00:09:14,210
So if I set this, for example, equal to five, that means I would show five book instances per page.

155
00:09:14,720 --> 00:09:19,210
This is a super easy to use attribute in case you and the pooling a ton of records.

156
00:09:19,220 --> 00:09:25,760
For example, if this person happens to have checked out 1000 books, we don't want a giant huge doom

157
00:09:25,760 --> 00:09:31,550
scroll page, a thousand books and say it will say five books per page and they can keep doing their

158
00:09:31,550 --> 00:09:32,780
pagination through that.

159
00:09:34,190 --> 00:09:34,490
Okay.

160
00:09:34,700 --> 00:09:36,510
Finally we have the actual query set.

161
00:09:36,590 --> 00:09:39,320
So I want to override the default query set.

162
00:09:39,530 --> 00:09:44,180
We talked about this a little bit in class based views, but for a list view, the default is just to

163
00:09:44,180 --> 00:09:45,800
query every single book instance.

164
00:09:45,800 --> 00:09:47,900
But I only want to do it for a specific user.

165
00:09:48,050 --> 00:09:48,860
So we'll do the following.

166
00:09:48,920 --> 00:09:54,110
We'll say the f get and it is query.

167
00:09:54,110 --> 00:09:58,880
Set our overwrite method here and we're going to delete some of this code here.

168
00:09:59,480 --> 00:10:04,370
So it's going to say get query set and then I have to return the actual query.

169
00:10:04,370 --> 00:10:11,540
I want to be executed, which means I want to look up my book instance, models, objects, and then

170
00:10:11,540 --> 00:10:12,650
I'm going to run a filter.

171
00:10:13,560 --> 00:10:16,530
Where my filter is equal to where the borrower.

172
00:10:17,770 --> 00:10:20,440
Is equal to make sure we spell that right.

173
00:10:20,470 --> 00:10:25,960
So the borrower field is equal to self dot request, dot user.

174
00:10:26,500 --> 00:10:27,730
So what's actually happening here?

175
00:10:28,180 --> 00:10:35,320
Remember, each view has this request which is living inside the session and the user's actually inside

176
00:10:35,350 --> 00:10:36,400
that request object.

177
00:10:36,790 --> 00:10:42,610
Essentially all that means is when a person is logged in and they're able to reach this template profile

178
00:10:42,610 --> 00:10:48,190
that HTML, then their request as they visit that page is going to have their user information.

179
00:10:48,280 --> 00:10:54,070
So I can actually grab that here in order to filter, book, instance, objects, filter, etc. And

180
00:10:54,070 --> 00:10:55,900
then if I want, I could order it by something.

181
00:10:56,710 --> 00:10:58,570
And just for clarity, I like putting.

182
00:11:00,530 --> 00:11:01,730
All here after that filter.

183
00:11:02,600 --> 00:11:05,720
But if you want, you can just leave it blank as well and do something like quarter by, etc..

184
00:11:06,050 --> 00:11:06,380
Okay.

185
00:11:06,440 --> 00:11:11,630
So we have book instance objects, filter it based off where the borrower is equal to self that request

186
00:11:11,630 --> 00:11:12,110
user.

187
00:11:12,740 --> 00:11:14,420
Okay, so let's save that.

188
00:11:14,420 --> 00:11:18,800
And finally, let's go ahead and connect it with a URL and a template.

189
00:11:18,830 --> 00:11:21,410
So I'm going to come back to my URLs that py for catalog.

190
00:11:22,870 --> 00:11:24,910
And we're going to say path.

191
00:11:26,520 --> 00:11:27,660
Let's just say it's profile.

192
00:11:29,750 --> 00:11:37,250
Forward slash and then this is views that and it's the kind of crazy name Chuck that books by user view

193
00:11:37,880 --> 00:11:39,590
and then I just need to call it as a view.

194
00:11:40,460 --> 00:11:40,970
There we go.

195
00:11:41,420 --> 00:11:43,370
Name and let's make it profile.

196
00:11:45,610 --> 00:11:46,640
So we'll save that.

197
00:11:46,660 --> 00:11:49,180
Don't forget your commas as you add more things to your patterns.

198
00:11:49,600 --> 00:11:51,310
And now let's create that profile.

199
00:11:51,310 --> 00:12:00,520
Templates will say you file profile the HTML and this is where it's actually connected to the books.

200
00:12:01,060 --> 00:12:02,380
So what can we do here?

201
00:12:02,560 --> 00:12:05,200
Well, it's actually going to pass in a list.

202
00:12:05,620 --> 00:12:10,630
So by default, remember the list view passes in something that is the name of the model like.

203
00:12:12,480 --> 00:12:13,260
Book instance.

204
00:12:13,860 --> 00:12:15,000
Let's make sure I spelled this right.

205
00:12:15,360 --> 00:12:20,640
It's going to be something like book instance, the name of the model underscore list as a single underscore

206
00:12:20,640 --> 00:12:20,880
there.

207
00:12:21,240 --> 00:12:24,090
That is what's actually passed in using the query.

208
00:12:24,120 --> 00:12:27,840
So it's model underscore list, which is the generic.

209
00:12:27,870 --> 00:12:29,400
Let's pass then for list view.

210
00:12:29,730 --> 00:12:33,150
If you didn't notice, this is the kind of thing I would look up in the documentation all the time.

211
00:12:33,720 --> 00:12:34,650
So let's check it out.

212
00:12:35,580 --> 00:12:36,270
I'm going to say.

213
00:12:39,470 --> 00:12:41,840
Welcome to your profile.

214
00:12:42,260 --> 00:12:47,600
Remember, it already has a log in required mixing, so I don't need to do anything of something like

215
00:12:47,600 --> 00:12:52,670
check out the users authenticated here because recall in my views I'm already making sure that they

216
00:12:52,670 --> 00:12:55,430
can only visit this page if they're logged in, which is nice.

217
00:12:55,430 --> 00:12:58,100
That means I don't need to say if users authenticate or anything like that.

218
00:12:58,550 --> 00:13:00,740
So we'll say welcome to your profile H2.

219
00:13:01,190 --> 00:13:04,340
Here are your books checked out.

220
00:13:06,220 --> 00:13:08,890
And then finally zooming in here a little bit so you can see this.

221
00:13:09,220 --> 00:13:10,480
So welcome to your profile.

222
00:13:10,510 --> 00:13:11,860
Here are your books checked out.

223
00:13:12,250 --> 00:13:18,760
And then let's go ahead and say for make a full list here for book in.

224
00:13:19,120 --> 00:13:25,390
And this is again, it's the name of the model lowercase book instance and then underscore list.

225
00:13:27,260 --> 00:13:34,160
And then I can just create a little list here so we can do something like, um, or make a little paragraph

226
00:13:34,160 --> 00:13:36,080
tag that gives the actual book.

227
00:13:40,580 --> 00:13:43,730
So I could do something like that that actually just passes in the book.

228
00:13:44,150 --> 00:13:48,010
Now I have to take a look at what our string representation is of an actual book.

229
00:13:48,020 --> 00:13:51,470
So if we've got a model stop by a book instance, do we actually have a string?

230
00:13:51,500 --> 00:13:53,300
It's just self ID, self book title.

231
00:13:53,330 --> 00:13:54,260
Okay, I think that should be fine.

232
00:13:55,190 --> 00:13:58,970
And obviously you could grab more information from that book object as we continued.

233
00:13:59,270 --> 00:14:06,020
So let's see if we didn't commit any bugs, we should probably have maybe something like an L statement

234
00:14:06,020 --> 00:14:09,740
that says, Hey, if this person doesn't have any books, it actually just instead of just saying,

235
00:14:09,740 --> 00:14:13,550
Here are your books checked out blank, you'll say something like, You have no books borrowed, etc.

236
00:14:13,550 --> 00:14:15,980
But it should be pretty okay given what we have here.

237
00:14:16,700 --> 00:14:19,780
So I'm coming back to my home page.

238
00:14:19,790 --> 00:14:22,660
I'm already logged in as my user in the admin.

239
00:14:22,670 --> 00:14:23,780
I already set that up.

240
00:14:23,930 --> 00:14:31,880
And so now what I'm going to do is go to catalog forward, slash profile, hit enter.

241
00:14:32,000 --> 00:14:32,720
Now I see.

242
00:14:32,750 --> 00:14:33,650
Welcome to your profile.

243
00:14:33,650 --> 00:14:34,280
Here are your books.

244
00:14:34,280 --> 00:14:37,370
Check out the unique I.D. and then super mystery.

245
00:14:37,640 --> 00:14:39,230
So it looks like everything's working.

246
00:14:39,830 --> 00:14:46,580
So what we did that's different in this particular lecture is I was able to actually log in as a user

247
00:14:46,580 --> 00:14:51,770
and see a page that is hyper specific to me as my specific user.

248
00:14:51,770 --> 00:14:53,810
And I don't need to worry about things like authentication.

249
00:14:54,080 --> 00:14:57,530
That's actually happening on the template side because I'm making sure to do that on the view side.

250
00:14:57,770 --> 00:15:01,160
Let me do a quick review of the steps we had to do to get here.

251
00:15:01,790 --> 00:15:10,370
So step number one was I had actually established a relationship between one of my models and a user.

252
00:15:10,580 --> 00:15:15,170
So whenever you're doing this sort of thing, there should be a relationship between the user and whatever

253
00:15:15,170 --> 00:15:16,610
model you actually want to show.

254
00:15:17,090 --> 00:15:19,850
That is for a foreign key connection.

255
00:15:19,850 --> 00:15:25,250
If you just wanted to show that user information, like just a user profile page, then you technically

256
00:15:25,250 --> 00:15:26,510
don't need to do what we did here.

257
00:15:26,720 --> 00:15:29,990
You just directly grab that user class object.

258
00:15:29,990 --> 00:15:31,400
So that's totally okay here.

259
00:15:31,670 --> 00:15:33,250
Remember, it's easy enough to do.

260
00:15:33,260 --> 00:15:37,530
You just had to import it and then you could just say, okay, I have a profile page.

261
00:15:37,530 --> 00:15:41,780
It says welcome user dot name and we actually have showed you how to do that user, that username,

262
00:15:41,780 --> 00:15:44,540
etc. We actually did that in the index page.

263
00:15:45,410 --> 00:15:47,510
Next, what I had to do is come to views that pie.

264
00:15:47,930 --> 00:15:53,690
And then as I mentioned, it's typically easier to think about this from the model perspective that

265
00:15:53,690 --> 00:15:54,930
is not the user.

266
00:15:55,070 --> 00:16:02,570
So we say something like, okay, think about book instances and then specify the query set to match

267
00:16:02,810 --> 00:16:04,370
that user requirement.

268
00:16:04,490 --> 00:16:06,830
This is typically the easier way to think about things.

269
00:16:07,190 --> 00:16:13,760
I could have gone a different way and said something like Do a user and then try to do a search for

270
00:16:13,790 --> 00:16:20,600
all their books so it would be like user and then grab all their book instances, etc. You can even

271
00:16:20,600 --> 00:16:22,850
try a template based approach for something like that.

272
00:16:22,850 --> 00:16:27,350
Just say book that checked out instances or whatever the user profile is.

273
00:16:27,650 --> 00:16:33,800
But that kind of requires you to begin to set up your own custom user where they actually have attributes

274
00:16:33,800 --> 00:16:38,480
associated for another model, which, given the way we could find it as a foreign key, it's easier

275
00:16:38,480 --> 00:16:41,880
to think about it from the book instances perspective and just filter off of that.

276
00:16:42,140 --> 00:16:47,720
So I'd recommend you do this approach as you continue your studies of Django, so to speak, and then

277
00:16:48,200 --> 00:16:53,270
we set it up with a template name and we just had to look up in the documentation to remember, okay,

278
00:16:53,330 --> 00:16:57,590
it's going to be the model underscore list for a generic list view and you can obviously continue to

279
00:16:57,590 --> 00:16:58,140
edit this.

280
00:16:58,550 --> 00:16:58,850
All right.

281
00:16:59,180 --> 00:17:00,830
That's it for this lecture.

282
00:17:01,160 --> 00:17:01,520
Thanks.

