Adding a CMS to Your Flask Web App Transcripts
Chapter: Saving content to the DB
Lecture: Creating the Redirects class
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
we created our page. The other thing we have to create is the redirect. Now, before I do, I'd realize I forgot to add the type annotations that'll
0:08
make this just a tiny bit nicer. So it's good in here is just add those that's going to string and so are
0:18
the rest. Actually, that's not only saved my thought, there we go. Okay, That way, if we say P equals page P,
0:34
he died Title notice that it knows it is a string, even though it's actually not a string.
0:42
It's what, These columns until it comes back from a database. But it is a string. Okay, this is decent. Let's go and create redirect based off of this.
0:52
You know, Rex Plural. That's what Your name in the file here as well This is a singular redirect like that. And it turns out this is super super easy.
1:04
Check this out. This is the same. This is the same Onley. These things change and we have a euro on. We have a short I do like this.
1:14
Let's say this is the girl and this is the short you're out. Why would I do that? Well, the short girl is the one that has to be non knowable,
1:23
unique and indexed. Right? That's the thing that we look for. They hit on our site and then we decide where we're going to send them off
1:30
Teoh, it's required, but we wouldn't One index there. You're not gonna ask. Show me all the pages that could go All the redirects
1:38
that could go to this URL That would be pretty weird. You guess You get added if you really wanted it and it doesn't have a content It has ah, name.
1:46
This is also requires will say no level is not true. Make a false. There we go. We've got our read Rex. And remember,
1:54
before they'll show up in the database, we have to put them over here. And let's try to keep them alphabetical like so run it.
2:05
It ran. That's a good sign. Refresh it. There's your read, Rex. Awesome. Okay, now we both have pages and read Rex modeled in
2:18
the database. That's pretty easy, isn't it? Yeah. Sequel Alchemy. Very, very sweet Love to work with.
2:24
It makes creating these tables according the database.