Adding a CMS to Your Flask Web App Transcripts
Chapter: The pages (our WordPress)
Lecture: Adding a CMS page with the admin
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
that we have our listing of are available pages. Obviously, the next thing to do is add them or edit them. So let's look at adding first.
0:08
Now we can just click here, right? Maybe not so much. We have written that part. So what we're gonna do now is implement this ad
0:16
page and just like the redirect version, and it is going to be basically the same thing.
0:22
So we're gonna more or less start by creating stuff that hasn't with editing, and the new page will just sort of fall out of it.
0:30
So let's start at the HTML side, and we're going to go and just make a copy of this and it redirect.
0:35
It's pretty similar. Honestly, we'll call this edit page again. Add at it sort of same thing.
0:43
So let's say back two pages and he won't go back to that pages list. And this will be if page ideas.
0:52
So it's gonna work our way through and just basically replace all the stuff to do the redirect redirect with pages. For the most part,
1:00
it's the same. But there's enough difference that I want to make sure we walk through it together So, you know,
1:06
pages don't have names. They have titles. They don't have short and long euros. They just have a single euro,
1:23
something like that. Perfect. Now, instead of having this part where we have the aura which we just did above what
1:32
we actually want is we want tohave rather than input. We want a text area because to type out our page contents,
1:39
it's gonna be multi line reform and George stuff. And that's not input type equals text.
1:44
It's like one liners. Text area is what we want and the name is gonna be content. I d is gonna be contents.
1:51
Let's make it a little wider and maybe a little taller. That's good. Let's also give it a placeholder, so people know what the type.
2:00
And here's a B content a HTML of your page and just like before we're initializing it to the data center over. So let's initialize this to contents,
2:12
and it's important that there's no spaces here. There's the angle bracket right there and there.
2:17
Otherwise, those spaces will actually appear as if somebody type them in or anything like that. Okay, and let's see, this will be a page idea and page.
2:29
Oh, okay, that was a lot. But, you know, I feel like we got it in the big difference here is this text area next door to come over here?
2:39
This is our views, and we're gonna dio sort of had a redirect. We're going to add age. So let's go over here and say Page and just
2:52
like before, we just work away through all right, making her way down. We're still going to create the view model,
3:05
but let's hold off on that for a minute. It's gonna be create page, and this will be VM. Assume it has a title, a girl and contents.
3:16
And when we're done and we don't take them to read Rex, we'll take them to yeah, pages plural. Next thing we want to do is work on that.
3:24
It would also need to create this method, but let's get the data from the view models first at over here,
3:29
but admin again find the closest thing that we can and make a copy. So that's this one at a page. Not when a pass in the page i d.
3:45
This is going to be page title and content.
4:10
All right, so far, nothing major. But we got to make sure that these do match up on the right and left
4:15
And this will be contents that's going to leave this. Obviously, that's not quite what we want. And then down here in this process form,
4:23
remember what we did. This is when we submitted. We're just going to reverse everything. So again, title. This is gonna be contents,
4:35
but we don't want a lower case it. Oh, here we go. Right now, we're gonna just do the validation. And we should be already with their view models.
4:49
No, not sure. I'm gonna require contents here. Maybe we want to be able to create the page with the title and then go
4:53
back and edit it. So let's just leave it like that. And this is gonna be page I d. So do they specify a page I d to edit?
5:01
But we couldn't find one. And then the page with I d whatever the page ideas doesn't exist in the reverse. If there's no page I d specified.
5:13
But we can get the page by its girl. That's a problem, right? We're gonna have a conflict between two pages of it
5:21
the same mural. So that's not gonna fly. So he will just say page with the same mural. All right, well again. Lots of stuff.
5:30
That's really similar. But it's not seem enough. That's one of fly through it. So here we go. We got our title,
5:37
Uriel. Contents were setting those up and or getting them back over here. It looks like that part's pretty good.
5:43
We've got our HTML. We've got our view model, and now we just have to import it. Oh, we haven't set the class name. Just the file name again. Page.
5:55
Here we go. Now we can import that. All right. Last last thing to do, I think, is gonna veto. Create this. Let's go on.
6:03
Right that function. It should be very similar to the create Redirect. But let's just make a copy.
6:13
All right? So if get page the Earl than it already exists, it will set the title and the contents,
6:38
and here we go. Two pages said it by the euro. And you know, the honestly that might do it. We're in a good place. I think this is gonna work.
6:50
There may be something I forgot, but you know, the only way to find out is to go and request it So let's click here and see who so good,
6:59
so good. You see? So the title of the pages will be simple test and this would just be test. And here we'll put our contents.
7:07
This is the make that bold contents of the test page down here says add. Remember, add page and page for the ad.
7:23
Thing is working. Right? Fingers crossed. What we're gonna get Who? Look at that. At the bottom. There. Simple test.
7:30
Oh, yes. That's actually pretty awesome. Let's go and view it. Oh, my goodness. There it is. There simple tests. This is the content.
7:40
Bold ID. Not with the embedded HTML, but the effect of what we wrote. Bolder contents off the test page. Oh, yeah, that's awesome.
7:48
So now we can see the pages again. We can't edit them because we haven't written that part yet. We're getting their start by ad.
7:55
Then we'll do at it. But it looks like this is working right. Slash Test is gonna open this page.
8:03
Perfect. So we have now gone and basically leverage what we did with the add new redirect to convert that over two pages.
8:11
Now, one of the challenges we have is this is a really crummy editor to write in. We're gonna make this much,
8:17
much better. There's tons of stuff we can do here. But this first pass the ability to write HTML and get it to be a page
8:24
of virtual page on our website here that's working. That's great. Let's do one more thing really,
8:30
really quickly. Let's just go and test that the validation here works well, I guess we can't edit. We go try another one,
8:38
though we go and try to create this. You see, these fields must be created so we could say simple test to it's
8:47
put in something wrong. And so we're gonna try to duplicate this right push us
8:53
back the server, and down here the page with the euro slash test already exists Oh, it must be tested to.
9:01
There we go. Now we have our test in our test two.