У нас вы можете посмотреть бесплатно Django Tutorial for Beginners 28 Creating a Base Template или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
More intensive courses : http://grow-book.blogspot.com/ Abstract video content already made to look at this beautiful navigation bar at the top of our webpage looking good and guys before we continue I know what you are thinking already alright so pretty much every single web page that we make for this website is going to have this navigation bar so what I'm going to do for every single template that i make i'm going to have to go and then copy this and let me just go ahead and copy that right there and then let's put in another page alright so now if i go to this one then this has the navigation bar to all right you know both of them are looking good and crap now we got do another template copy this code clapping and copy this code popping in well then our teacher our boss comes Austin is ik Bucky you need another button on here re so I'm going to have to go in every single template and add a button one by one no no guys whenever we set it up this way we're breaking the number one rule of software design that rule is never repeat yourself if ever you're making a website or a piece of software and you find yourself having the same code or doing the same thing over and over and over again then you're doing something wrong so instead of having the same code in every single template let's go ahead and think about this the way we want to set up our site is we're basically going to have it where every basic structure is identical in other words we have the same background we have the navigation bar this never changes no matter what pager on and the basic styling as well so would be awesome if we could kind of make a generic blueprint to say okay we're going to have this genetic blueprint and then this is the only section that we need to change and that way if we just have it in one location we just have to you know add another button or maybe change the background color of this and updates on every single page that would be fantastic so let's go ahead and set it up that way so instead of having this on every single template what we're going to do is we're going to right click here and we're going to make an HTML file called base HTML so this is basically going to be our generic blueprint and it's already set up for us and again this is just a regular HTML file so what parts do we want the same on every page where all this this of course it needs a heading the title going to have viber and of course we need these on every single page so again in base the HTML just go ahead and plop in whatever you're gonna need on every single page for your website alright so we need all of those includes on every single page now what else well we know that every single page is also going to have this same navigation bar at the top so i'm going to go ahead and copy this can go ahead and cut it and it's gonna go right inside the body so let me pop it right in there re so there we go and make sure it's deleted from everywhere alright so this is the basic structure of every single page so we have all of our imports or includes and then we have our navigation bar but we also need a way to include other stuff in the body right under the navigation bar so how do we define that in our base template well what we do is we actually make kind of a variable and you can name it anything you want but it's called a block so what you write is block in other words after this we're going to include a block of code what it is well it might change but that's basically what we're going to do and i'm just going to name this body but again you can name this block anything you want and then you just need to write in block and block so what we're seeing right here is later on we're going to include a block of code and this is where it starts in this zoo is where and so basically just plop it right in there and you guys are going to see why it has a starting and ending spot later on but that is how you do it so now let's actually go ahead in one of our views in use this template so the first thing we need to do is actually include or say hey Django we are using this template and this is what we're going to want to appear in that block section so how do we do that well in order to include a template it's called extends so we're going to include music / base HTML so in other words what we did is reaches pretty much took all of this and plopped it right in there now another piece of the puzzle we need to fill in is now it's asking okay so you said that something was going here and block body on what do you want me to put right there well all you have to do is this whatever chunk of code which is essentially all this that we want to put right here we just surround it with the sam ...