#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: Creating the document

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right, looks like our categories are working, so we can delete that bit.
0:03 Now, here we have the To-Do, Create a Document.
0:07 What we need to do because the security we put
0:09 on our document, our database,
0:11 we need to put over here.
0:13 Let's get rid of this output so we have more room...
0:16 ...to our data layer and add one more function,
0:18 and just for time's sake, I'll paste this in,
0:20 it's really simple.
0:21 So we're going to call Add a Document, and it's going to take
0:23 a Category Name, a Contents, and a Views.
0:26 We also have that created
0:28 which we're going to generate on the server,
0:30 and a little print of what we're going to do.
0:33 And then we'll come over here,
0:34 and we'll call Category by Name,
0:36 give it a category name
0:37 'cause when you have these linked tables,
0:39 you can't just put a value
0:41 that would determine their relationship,
0:43 you actually have to put the row,
0:44 so we're going to get the row back,
0:46 and then set the relationship this way.
0:49 And we have...
0:51 Make sure we have this right here...
0:52 Name, Created, Content, Views, and Category.
0:56 So this needs to be Name,
0:58 Content, Views,
0:59 Created, and Category.
1:00 It looks good.
1:01 So we're just going to go and create this.
1:02 Now, all we have to do is call this Add Doc here.
1:12 There it is.
1:15 And what does it take?
1:16 It's going to take-
1:17 Look at that, it's pretty awesome to show this-
1:18 it takes the document name,
1:21 Name, Category,
1:23 Contents, and Views,
1:25 and let's just put zero for views when we create it.
1:30 So Name,
1:36 something like that,
1:44 So this selected value here,
1:47 that's just going to be the name,
1:49 and that's what we'll use in our look-up on the server site,
1:51 and the Content.
1:58 Something as well.
1:59 All right, so that should do it.
2:01 Let's see if this works.
2:09 So this is going to be some documentation.
2:12 All right, let's see if this works.
2:13 Create Document,
2:15 ha-ha, datetime and Data Layer.
2:19 Yes, yes.
2:20 Import datetime.
2:22 So close, let's try again.
2:28 Alright, let's try it with this.
2:32 Boom. Look at that.
2:33 On the server it says it's creating the new document.
2:35 Does that really mean it was created?
2:36 Let's go to the database.
2:43 Oh my goodness!
2:44 There it is.
2:45 Look! That's it.
2:46 And we linked it over to the documentation.
2:49 Now even the categories.
2:50 That's so super awesome.
2:52 Love it.