Django: Getting Started Transcripts
Chapter: HTML Templates
Lecture: Building the home page with layout
Login or purchase this course to watch this video and the rest of the course contents.
0:00 building a homepage will be similar to building the about page. The only tricky part will be the U R.
0:06 L. You have to register the slash with a view just like any other U R L. Because that's in the base,
0:14 I'll be defining it inside of alexandria URLs instead of the home dot Earl's place. Even though that's the app, I'm going to put the view in,
0:23 it's kind of the exception to the rule offscreen I created home dot HTML. You'll notice except for the content blocks saying something different.
0:32 It's very similar to about dot HTML. Not the fanciest thing, but good enough for now, back in views, there's the view for the homepage again,
0:47 very similar to the about page. And finally, just to register that slash remember that all the girls in home dot
0:57 girls are going to be mapped under slash home so you can't put the route mapping of base slash inside this file.
1:05 This is a bit of a step away from the encapsulation that you might want for your app but like I said,
1:11 exception to the rule, let me open up alexandria URLs. And the first thing I have to do is import the views from the home app
1:21 Technically I only need the home view, but this is usually how I import views as a habit.
1:28 So I'm going to do it the same way I normally do as all view files are named views dot pi I usually use the as clause of the import to make
1:39 it clear where this is from. So, instead of just importing home views, I import it as home underscore views now,
1:48 I need to add the registration all you are L start with slash to get to say hello, you type the host name,
1:56 then slash then say hello, but when it is registered, the leading slash isn't used Django does that for you?
2:04 Following that logic. The base URL for the site is just the empty string. So I mapped the empty string to the home function in the home apps
2:18 views file and everything is set. I've still got the DEV server running in the background so let me switch to the
2:25 browser, Reload that previously problematic page and look at that your home.