1
00:00:05,350 --> 00:00:07,040
Welcome back, everyone, to this lecture.

2
00:00:07,060 --> 00:00:10,690
We're going to begin setting up some views for our actual pages.

3
00:00:10,930 --> 00:00:16,090
Things like a homepage that can display all the books available for checkout or the status of all the

4
00:00:16,090 --> 00:00:16,990
books in the library.

5
00:00:17,410 --> 00:00:19,390
Let's go ahead and head back to our code editor.

6
00:00:22,210 --> 00:00:22,540
Okay.

7
00:00:22,540 --> 00:00:24,580
So here we are back at our code editor.

8
00:00:24,970 --> 00:00:27,400
Let's go back to our views that PI.

9
00:00:27,430 --> 00:00:32,140
Remember, we actually already had a very simple index page that just responded, hello.

10
00:00:32,590 --> 00:00:36,940
Let's now use models to start displaying information from the models.

11
00:00:37,600 --> 00:00:40,150
So say from that model's imports.

12
00:00:40,780 --> 00:00:42,160
And I'm going to import book.

13
00:00:42,520 --> 00:00:45,850
Let's say author book instance.

14
00:00:45,850 --> 00:00:49,840
And we can also say the genre in language whether or not will actually display this.

15
00:00:50,170 --> 00:00:51,190
We can decide later on.

16
00:00:51,820 --> 00:00:56,380
So here we're going to have just a simple view function and let's generate some counts of some of the

17
00:00:56,380 --> 00:00:58,150
main objects in our databases.

18
00:00:58,420 --> 00:01:01,120
For example, the number of books, maybe that's something we want to display.

19
00:01:01,930 --> 00:01:05,410
So I can say book the objects the all.

20
00:01:05,650 --> 00:01:07,630
And then simply request a count of them.

21
00:01:08,350 --> 00:01:11,350
And then I can also say, what are the number of instances of books?

22
00:01:11,740 --> 00:01:16,660
So remember, this is books as in like the titles, but how many actual copies do we have available?

23
00:01:16,690 --> 00:01:19,880
So a number of instances would be very similar.

24
00:01:19,900 --> 00:01:21,220
It would just be book instance.

25
00:01:22,520 --> 00:01:24,230
Objects all.

26
00:01:24,620 --> 00:01:29,540
And currently the way we've set this up, there's just one copy of that mystery novel, and then maybe

27
00:01:29,540 --> 00:01:31,310
we can even have a number available.

28
00:01:31,340 --> 00:01:34,220
So, for example, number of instances.

29
00:01:35,240 --> 00:01:39,230
Available would just be the book instance.

30
00:01:40,400 --> 00:01:42,710
Objects and then we filter.

31
00:01:42,950 --> 00:01:43,970
So what do I filter?

32
00:01:44,000 --> 00:01:46,940
Well, I could filter based off its status.

33
00:01:47,450 --> 00:01:54,750
So I say status underscore, underscore exact number A was our code for being available.

34
00:01:55,250 --> 00:01:57,280
And then from there, I could create that count.

35
00:01:58,010 --> 00:02:02,480
So so far reporting back the number of books, essentially them are titles hold a library, number of

36
00:02:02,480 --> 00:02:03,060
instances.

37
00:02:03,060 --> 00:02:06,410
So total physical copies, number of instances available for checkout.

38
00:02:06,770 --> 00:02:11,750
And what I can also do is just say number of authors, etc., but eventually we have to pass all this

39
00:02:11,750 --> 00:02:12,550
information back.

40
00:02:12,560 --> 00:02:18,710
So I'm going to say return, render the request and here I'm going to reference a template that doesn't

41
00:02:18,710 --> 00:02:19,250
exist yet.

42
00:02:19,820 --> 00:02:21,050
Index each HTML.

43
00:02:21,470 --> 00:02:23,510
I'm going to pass this back as context.

44
00:02:23,960 --> 00:02:26,210
So let's actually create a context dictionary for this.

45
00:02:26,210 --> 00:02:27,920
Also, context is equal to context.

46
00:02:28,580 --> 00:02:31,310
But then I'm going to actually paste this in.

47
00:02:32,520 --> 00:02:35,970
So here we'll say context is equal to the dictionary.

48
00:02:36,960 --> 00:02:40,230
And we're just going to have the key value pairs match up to their names.

49
00:02:41,040 --> 00:02:43,950
So this will be equal to number of books, comma.

50
00:02:45,240 --> 00:02:46,940
Number of instances.

51
00:02:49,030 --> 00:02:51,310
His number of instances, comma.

52
00:02:52,240 --> 00:02:54,100
And the number of instances available.

53
00:02:56,210 --> 00:02:57,740
Number instances available.

54
00:02:59,340 --> 00:03:01,560
Common instances of ill.

55
00:03:02,930 --> 00:03:03,410
There we go.

56
00:03:04,010 --> 00:03:05,930
Okay, so here's our context.

57
00:03:05,940 --> 00:03:11,110
We're passing it back to index that each HTML, which means I actually need to post that in somewhere.

58
00:03:11,120 --> 00:03:14,690
So let's create a new file here.

59
00:03:14,690 --> 00:03:18,110
So we'll say new folder, actually templates.

60
00:03:18,110 --> 00:03:22,310
And then inside of templates, we're going to see a new folder called catalog.

61
00:03:23,540 --> 00:03:28,700
And then inside of this is where we're going to create that first index that each HTML file.

62
00:03:28,850 --> 00:03:35,390
So now I can start typing out each HTML and then in fact, we can make this a full dock so I can say

63
00:03:35,390 --> 00:03:35,840
talk.

64
00:03:36,470 --> 00:03:39,170
And then inside the body, have a heading saying.

65
00:03:40,100 --> 00:03:40,940
Homepage.

66
00:03:42,780 --> 00:03:45,330
And then I could start actually inserting things.

67
00:03:45,420 --> 00:03:50,490
So, for example, I could say, go ahead and inserts the number of books we have.

68
00:03:51,450 --> 00:03:52,530
So a paragraph tag.

69
00:03:52,890 --> 00:03:53,280
Um.

70
00:03:54,350 --> 00:03:55,190
Total books.

71
00:03:55,460 --> 00:03:57,710
And then this is where you would actually start inserting things.

72
00:03:58,670 --> 00:04:00,560
So I just do that with a call here.

73
00:04:02,030 --> 00:04:03,410
Double set of brackets.

74
00:04:03,410 --> 00:04:07,460
And for example, I can see a number of books.

75
00:04:07,940 --> 00:04:11,000
Okay, let's just do one more example, since I'm sure you guys kind of get it by now.

76
00:04:11,540 --> 00:04:12,920
So a number available.

77
00:04:15,100 --> 00:04:15,870
Here we go.

78
00:04:15,880 --> 00:04:20,980
And let's have the say something like number of instances available.

79
00:04:22,940 --> 00:04:25,100
Now, remember, we're passing that back through the context.

80
00:04:25,100 --> 00:04:27,230
So I'm going to go ahead and save this.

81
00:04:28,520 --> 00:04:32,240
And then for now, last thing I want to do to make sure it's actually all gets linked up and displayed

82
00:04:32,630 --> 00:04:34,280
because it's under templates and catalogue.

83
00:04:34,280 --> 00:04:38,600
What I could do for simplicity is just say, Here we go, here.

84
00:04:39,950 --> 00:04:42,470
Catalog forward slash index each HTML.

85
00:04:43,740 --> 00:04:44,060
Okay.

86
00:04:44,070 --> 00:04:50,370
And then if you actually come here to your homepage, you should now see something that looks like this.

87
00:04:50,370 --> 00:04:51,540
Let me zoom in for you.

88
00:04:52,050 --> 00:04:55,770
You can see it says total books are one number available is zero.

89
00:04:56,010 --> 00:05:00,150
And that matches up to what I created last time I did create a book, but then I said it was checked

90
00:05:00,150 --> 00:05:01,410
out and it was due tomorrow.

91
00:05:01,830 --> 00:05:06,180
So clearly we have a connection on the homepage and you could begin to link any information.

92
00:05:06,190 --> 00:05:08,190
Made a small little typo there, but no big deal.

93
00:05:08,730 --> 00:05:15,300
So we want to begin to explore is the ability to do things like edit maybe or add, update, delete,

94
00:05:15,300 --> 00:05:17,580
etc. based on certain views.

95
00:05:17,730 --> 00:05:23,940
But what I want to eventually add in is a capability to only be able to visit some of these views based

96
00:05:23,940 --> 00:05:25,650
off user authentication.

97
00:05:25,710 --> 00:05:28,140
So we're going to set up a couple of more views.

98
00:05:28,140 --> 00:05:33,570
We're not going to do absolutely all of them, but you can eventually add in more and more views and

99
00:05:33,570 --> 00:05:35,280
you can check out the full code if you want.

100
00:05:35,310 --> 00:05:40,290
Or just a code that we've worked on here together in this video but eventually want to do is restrict

101
00:05:40,290 --> 00:05:43,830
views or restrict capabilities based off the user themselves.

102
00:05:43,830 --> 00:05:48,630
Like are you actually an official user and do you have permission to do something on our website?

103
00:05:48,780 --> 00:05:49,740
Like a librarian.

104
00:05:51,430 --> 00:05:57,790
So for right now, let's create a simple class based view that is going to allow anybody right now on

105
00:05:57,790 --> 00:05:59,530
the page to create a book.

106
00:05:59,920 --> 00:06:06,070
Then we'll switch over now that we've done all the work to set up a very skeleton website of a library

107
00:06:06,430 --> 00:06:12,350
to actually show you, Hey, this is how you can mix in the permissions of requirements.

108
00:06:12,370 --> 00:06:16,090
So let's go ahead and create one more view.

109
00:06:16,360 --> 00:06:20,320
I'll actually do this one as a class based view so we can see that as an example here.

110
00:06:20,830 --> 00:06:22,030
So we're going to say from.

111
00:06:24,100 --> 00:06:28,090
Django doc views the generic.

112
00:06:29,050 --> 00:06:31,090
And I'm going to import.

113
00:06:32,840 --> 00:06:35,750
And let's import a very simple, creative view.

114
00:06:37,250 --> 00:06:42,230
And if we wanted to, I could continue doing this with a model view, but we'll keep things simple for

115
00:06:42,230 --> 00:06:42,450
now.

116
00:06:42,470 --> 00:06:48,560
So I have this very simple view, and then what I'm going to do is create a view that essentially connects

117
00:06:48,560 --> 00:06:49,430
to a model.

118
00:06:50,240 --> 00:06:51,890
So here we're going to say.

119
00:06:53,400 --> 00:06:56,410
Class book creates.

120
00:06:56,460 --> 00:06:58,870
So the ability to create a new book keep minds.

121
00:06:58,890 --> 00:07:01,560
Not the creation of the book instance, just the creation of a book.

122
00:07:02,130 --> 00:07:04,500
And then we're going to inherit from create view.

123
00:07:06,300 --> 00:07:09,930
And you could do this for creation of authors, creation of languages, etc..

124
00:07:10,200 --> 00:07:12,960
Keep things simple for now so we don't just do a bunch of duplicate work.

125
00:07:13,380 --> 00:07:17,970
So say book, create, create view, connect it to a model.

126
00:07:18,810 --> 00:07:20,340
So going to connect it to the book model.

127
00:07:20,400 --> 00:07:22,110
Remember, I already imported that up here.

128
00:07:23,160 --> 00:07:25,950
And then what I'm going to do is say the fields that they can create.

129
00:07:26,670 --> 00:07:29,070
So we're just going to say all.

130
00:07:31,210 --> 00:07:33,640
And then if you wanted to continue, you could give this a success.

131
00:07:33,670 --> 00:07:38,860
Earl Maybe we'll add that in later, but let's actually connect this to the default, remember, for

132
00:07:38,860 --> 00:07:39,720
create view.

133
00:07:40,060 --> 00:07:45,550
Sometimes it's easy to forget, but it's going to be your model underscore form that each HTML, which

134
00:07:45,550 --> 00:07:52,990
means it will be looking for the book underscore form the HTML inside templates, which means are going

135
00:07:52,990 --> 00:07:59,920
to come in here to catalog, going to create a new file and we are going to call this book underscore

136
00:07:59,920 --> 00:08:07,360
form, start each HTML and then here we'll just go ahead and say create new book.

137
00:08:08,750 --> 00:08:09,710
And then the form.

138
00:08:10,700 --> 00:08:11,420
Will be.

139
00:08:11,810 --> 00:08:15,410
We don't need an action here, but we do need a method or same method is post.

140
00:08:16,870 --> 00:08:18,070
Is equal to post.

141
00:08:20,120 --> 00:08:22,010
And then we have the CSR a token.

142
00:08:24,010 --> 00:08:25,690
So or a token.

143
00:08:25,960 --> 00:08:26,560
There we go.

144
00:08:26,770 --> 00:08:27,050
Oops.

145
00:08:27,430 --> 00:08:29,550
Looks like XLE auto completed that twice.

146
00:08:30,880 --> 00:08:31,400
There you go.

147
00:08:31,420 --> 00:08:34,900
There's a CSR token and then we'll also just pass in the form.

148
00:08:35,799 --> 00:08:38,890
So it's a form and we'll make this as paragraph.

149
00:08:40,000 --> 00:08:47,050
Finally, the input button itself will say input and it's going to be just input type is submit.

150
00:08:47,980 --> 00:08:49,780
The value can be something like.

151
00:08:51,670 --> 00:08:53,350
Create book or just create.

152
00:08:54,290 --> 00:08:54,590
Okay.

153
00:08:54,950 --> 00:08:56,600
So make sure you save those views as well.

154
00:08:56,960 --> 00:08:58,940
We create a very simple create view.

155
00:08:59,210 --> 00:09:03,890
Obviously, you can use the power of generic views to create list views, to list all the books that

156
00:09:03,890 --> 00:09:06,020
are available, unavailable, etc..

157
00:09:06,260 --> 00:09:07,820
We already know how to do that with filters.

158
00:09:08,060 --> 00:09:13,130
You can do delete views for deleting books, but right now keeping it as simple as possible in this

159
00:09:13,130 --> 00:09:16,520
skeleton for the purposes of understanding users later on.

160
00:09:17,000 --> 00:09:21,410
So we have this create view but have actually linked it to any specific URL.

161
00:09:21,830 --> 00:09:26,960
So we'll come back to your URLs here at the actually, we need to go to the catalog level.

162
00:09:27,470 --> 00:09:28,610
So let me click here.

163
00:09:29,030 --> 00:09:29,360
Okay.

164
00:09:29,360 --> 00:09:34,520
So we have the home page, but we don't have an actual view for the creation or the excuse me, the

165
00:09:34,520 --> 00:09:35,570
URL for the creation.

166
00:09:36,110 --> 00:09:37,880
So to fix that, it's pretty simple.

167
00:09:37,880 --> 00:09:44,300
We just are going to say from the import views or what I can also say is actually we'll just leave it

168
00:09:44,300 --> 00:09:44,810
as views.

169
00:09:45,110 --> 00:09:46,310
I don't mind calling it again.

170
00:09:46,910 --> 00:09:51,530
I'm going to set a path called, let's say, create book should be okay.

171
00:09:52,460 --> 00:09:59,390
And then I'm going to say this is VUSE Dot and then we called this book Create.

172
00:10:00,910 --> 00:10:01,420
Here we go.

173
00:10:01,460 --> 00:10:05,320
Put creates as view because remember these actually expect functions.

174
00:10:06,300 --> 00:10:09,750
And then we'll say the name of this is Create Book.

175
00:10:11,720 --> 00:10:12,020
Okay.

176
00:10:12,170 --> 00:10:15,980
So that should now link it to a URL pattern.

177
00:10:16,400 --> 00:10:23,420
So if you go to homepage forward slash, create book or actually catalog for its last great book, then

178
00:10:23,420 --> 00:10:26,240
it should take you to this view for the creation view.

179
00:10:26,540 --> 00:10:28,060
And let's make sure that's all working.

180
00:10:28,070 --> 00:10:30,650
We may have committed a typo along the way, but no problems.

181
00:10:30,920 --> 00:10:32,510
We should be able to fix it.

182
00:10:33,020 --> 00:10:36,710
So here I am at my home page for the catalog.

183
00:10:37,100 --> 00:10:39,140
Let's go to create book.

184
00:10:39,320 --> 00:10:41,690
Let me make sure that was the actual URL that we just described.

185
00:10:42,890 --> 00:10:43,620
Create book.

186
00:10:43,640 --> 00:10:49,490
So I'm going to go there, create underscore book, and I bring that in here.

187
00:10:49,940 --> 00:10:52,460
So we do see the ability to create a book.

188
00:10:52,880 --> 00:10:57,710
So I'm going to say the title is brand new test book.

189
00:10:58,790 --> 00:11:02,140
The author notice it's a dropdown so we only have Jose Pretty.

190
00:11:02,180 --> 00:11:09,900
The choose from summary is test book obviously super ugly form, but you get the idea ISBN number.

191
00:11:09,920 --> 00:11:13,820
This is something you would like look up on the internet and the mystery.

192
00:11:14,750 --> 00:11:17,210
I think the book's like 13 some slowly, something like that.

193
00:11:17,660 --> 00:11:18,890
We'll also have this one B mystery.

194
00:11:19,190 --> 00:11:21,740
We could create genres if we wanted to.

195
00:11:21,740 --> 00:11:25,910
And then English here from the dropdown some hit create make sure we don't get error.

196
00:11:26,950 --> 00:11:29,670
It looks like we do get a reverse match error.

197
00:11:29,670 --> 00:11:31,470
So book detail is not a valid.

198
00:11:31,920 --> 00:11:32,550
Oh, I see.

199
00:11:32,580 --> 00:11:38,280
So basically by default, the success page is to go for the book detail.

200
00:11:38,550 --> 00:11:43,080
But currently, we don't technically have a view that shows the book detail.

201
00:11:43,470 --> 00:11:48,390
So while I believe that book should have been created and we can check the admin to actually check if

202
00:11:48,390 --> 00:11:54,600
that's true, currently there's no reverse functionality to go to the book detail page.

203
00:11:54,630 --> 00:12:00,060
So what I'm going to do here is I'm actually going to go to admin and confirm that book was created

204
00:12:00,470 --> 00:12:01,890
just to check that our form is working.

205
00:12:02,370 --> 00:12:06,750
So here we go to books and I can see my brand new test book was created.

206
00:12:07,140 --> 00:12:12,000
It's just that there was no success URL to go to and the default want us to go to detail view.

207
00:12:12,030 --> 00:12:13,110
So we have two options here.

208
00:12:13,350 --> 00:12:16,320
One is to manually override the success URL.

209
00:12:16,320 --> 00:12:17,520
We've actually done that before.

210
00:12:18,150 --> 00:12:19,260
It's pretty straightforward.

211
00:12:19,260 --> 00:12:21,030
You just say you come here.

212
00:12:22,020 --> 00:12:31,830
To views that pie and say success IRL and then do a reverse lazy lookup for whatever view you want to

213
00:12:31,830 --> 00:12:32,310
go to.

214
00:12:32,610 --> 00:12:36,910
Now by default, it is the detail view for that particular book.

215
00:12:37,260 --> 00:12:41,070
So the other option we have here is to create a detailed view.

216
00:12:41,370 --> 00:12:47,940
So I could come up here and from create view also imports detail view.

217
00:12:48,720 --> 00:12:49,980
So it's not so bad to do that.

218
00:12:50,400 --> 00:12:53,580
We'll go ahead and create a new class called Book Detail.

219
00:12:54,830 --> 00:12:58,490
And we're going to call this detail view imported from.

220
00:12:59,570 --> 00:13:06,500
And then we're just going to connect this to model is equal to book there which means I need a new template.

221
00:13:06,620 --> 00:13:13,820
So we'll say new file and this will we book underscore detail by each HTML.

222
00:13:14,390 --> 00:13:17,840
Simply going to say detail for book.

223
00:13:18,900 --> 00:13:21,570
And then this passes in that actual book model.

224
00:13:21,840 --> 00:13:22,950
So we'll save that.

225
00:13:23,610 --> 00:13:24,770
Go to views.

226
00:13:24,780 --> 00:13:26,100
Save that connection.

227
00:13:26,880 --> 00:13:29,130
So make sure you save that connection there.

228
00:13:29,520 --> 00:13:34,320
And so now the redirect after creating a book should take you to that book detail page, which we have

229
00:13:34,320 --> 00:13:34,530
here.

230
00:13:34,560 --> 00:13:36,930
Very simple, but it should be working.

231
00:13:36,930 --> 00:13:40,500
So I'm going to go back to my catalog.

232
00:13:41,040 --> 00:13:42,840
Let's go back to my home page here.

233
00:13:43,410 --> 00:13:45,160
So we're back to the home page.

234
00:13:45,180 --> 00:13:48,120
It looks like I did actually create that book, but we don't have that detail page yet.

235
00:13:48,570 --> 00:13:55,260
So we're going to go to catalog and this is Book Create or might have been create ebook loops.

236
00:13:55,260 --> 00:13:57,840
Let me create underscore book.

237
00:13:58,320 --> 00:13:59,580
There we go, create a new book.

238
00:13:59,970 --> 00:14:01,770
So we're going to call this second test.

239
00:14:03,210 --> 00:14:04,440
Same authors before.

240
00:14:04,800 --> 00:14:06,750
We're going to call this my second test book.

241
00:14:07,560 --> 00:14:09,150
I have to be number 1 to 3.

242
00:14:09,870 --> 00:14:12,660
It's also a mystery, although I believe some of these we said we could leave.

243
00:14:12,660 --> 00:14:15,240
No, it's in English going to create this.

244
00:14:16,020 --> 00:14:17,370
And it looks like we still have an error here.

245
00:14:17,370 --> 00:14:18,390
So let's dive deeper.

246
00:14:18,850 --> 00:14:21,600
Oh, it's because we forgot to actually make the URL matching.

247
00:14:21,600 --> 00:14:22,740
So almost none.

248
00:14:23,220 --> 00:14:25,230
And to come back here to your URLs.

249
00:14:26,690 --> 00:14:28,340
And now let's fit that in.

250
00:14:29,120 --> 00:14:30,050
So say path.

251
00:14:30,350 --> 00:14:33,170
And then here is where we're actually going to have the detail for the path.

252
00:14:33,950 --> 00:14:38,390
So in that case, we simply insert the detail view.

253
00:14:38,420 --> 00:14:40,850
So we're going to say this is going to be book.

254
00:14:42,170 --> 00:14:43,850
And this can be integer.

255
00:14:45,540 --> 00:14:54,610
Pick forward slash and then I could then say views dot and then that would be my book detail you will

256
00:14:54,660 --> 00:14:55,380
see book.

257
00:14:56,330 --> 00:14:56,960
Detail.

258
00:14:58,870 --> 00:14:59,830
As you.

259
00:15:01,200 --> 00:15:04,170
And I could give it the name detail book.

260
00:15:05,590 --> 00:15:07,060
And save that right there.

261
00:15:08,350 --> 00:15:10,270
All right, so let's try this one more time here.

262
00:15:11,110 --> 00:15:12,520
Make sure we're not committing an error.

263
00:15:13,120 --> 00:15:16,630
So let's go back to Create Book, which is going to be the third book.

264
00:15:17,890 --> 00:15:19,150
So a third test book.

265
00:15:20,920 --> 00:15:21,850
And I'm going to type.

266
00:15:22,030 --> 00:15:24,400
I remembered you all this time.

267
00:15:26,090 --> 00:15:27,170
ISBN number.

268
00:15:27,200 --> 00:15:28,640
Remember, these have to be unique.

269
00:15:28,640 --> 00:15:29,420
I believe so.

270
00:15:30,630 --> 00:15:33,180
You make an error if you keep repeating ISBN numbers.

271
00:15:34,020 --> 00:15:34,950
Let's create.

272
00:15:35,930 --> 00:15:37,900
And it looks like we actually used the wrong name.

273
00:15:38,150 --> 00:15:38,900
Book detail.

274
00:15:38,900 --> 00:15:39,800
Not detail.

275
00:15:39,810 --> 00:15:40,160
Book.

276
00:15:41,080 --> 00:15:43,900
So say book detail.

277
00:15:44,770 --> 00:15:46,720
Save that and.

278
00:15:47,980 --> 00:15:49,050
One more time here.

279
00:15:49,060 --> 00:15:51,580
So this will now be my fourth test book.

280
00:15:52,780 --> 00:15:53,950
So a fourth test book.

281
00:15:53,950 --> 00:15:59,440
Here is time and selected the correct name.

282
00:16:00,660 --> 00:16:04,990
Let's give this a unique spin it creates.

283
00:16:05,010 --> 00:16:05,760
And there we go.

284
00:16:06,180 --> 00:16:06,480
Okay.

285
00:16:06,810 --> 00:16:11,760
So let me go through the steps that I did to remember how to actually get this detailed book to work.

286
00:16:12,270 --> 00:16:18,660
So coming back here, we come to our views and we create this very simple view which is based off the

287
00:16:18,660 --> 00:16:19,650
generic create view.

288
00:16:20,100 --> 00:16:20,970
So that worked out.

289
00:16:21,000 --> 00:16:23,610
But remember, in order to use that view, you have to have the form.

290
00:16:23,970 --> 00:16:27,990
So we have the form and we connected that through URLs as shown here create book.

291
00:16:28,410 --> 00:16:33,270
Then after creating that book, the default is to go to that book's detail page.

292
00:16:33,660 --> 00:16:35,670
Now, that's where I forgot to actually create the view.

293
00:16:35,730 --> 00:16:37,590
So I created the book detail page.

294
00:16:37,950 --> 00:16:41,400
Then I got the error that said, I can't find this book detail view.

295
00:16:41,640 --> 00:16:45,300
Well, that's because I hadn't actually connected it through your URL, so I connected through your

296
00:16:45,300 --> 00:16:45,810
URL.

297
00:16:45,810 --> 00:16:51,360
But then the default name I was looking for was book underscore detail, not detail or score book.

298
00:16:51,370 --> 00:16:53,880
And it actually told us that in the error message.

299
00:16:54,210 --> 00:16:59,880
But now I should have enough of a skeleton to focus on users.

300
00:17:00,060 --> 00:17:02,160
So what do I actually have so far?

301
00:17:02,700 --> 00:17:08,849
I have a home page that has the ability to look up things like books, the number available, etc. And

302
00:17:08,849 --> 00:17:12,569
then I also have the ability to create new books.

303
00:17:12,599 --> 00:17:17,730
So if I go to base of my URLs for slash catalog, for slash create book.

304
00:17:18,089 --> 00:17:18,930
So if I go here.

305
00:17:21,180 --> 00:17:23,970
Then I have the ability to create a new book and go to its detail page.

306
00:17:24,210 --> 00:17:27,880
So that is the entire skeleton we need to begin to explore.

307
00:17:27,900 --> 00:17:32,220
User Sessions And the main idea here is based off these views.

308
00:17:32,220 --> 00:17:37,740
We already know how to create all kinds of views, such as lists, views, detailed views, all these

309
00:17:37,830 --> 00:17:39,030
different class based views.

310
00:17:39,450 --> 00:17:44,990
But what if I only want someone I know like a special librarian, to be able to create new books?

311
00:17:45,000 --> 00:17:49,200
I don't want everyone visiting the library site to have access to this form.

312
00:17:49,620 --> 00:17:55,440
So essentially when we're thinking about users, we only want people to have access to certain pages.

313
00:17:55,440 --> 00:17:59,160
And that's what I'm going to focus on next now that we have the skeleton code.

314
00:17:59,430 --> 00:18:01,100
So I'll see you in the next lecture.

