У нас вы можете посмотреть бесплатно Django Tutorial for Beginners 29 Generic Views или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
More intensive courses : http://grow-book.blogspot.com/ Abstract video content alright guys welcome back in this video I want to talk to you guys about generic views so first let me explain what they are so basically whenever you make a website or go to website you're going to notice that all the websites that you go to kind of have the same pattern they either display a list of objects or they have details about one object to different pages so if you think about our website like youtube whenever you search for video it just has a list of all the videos that you can scroll through and find your video and then when you click one it has details about that video of course the player and all the comments in related videos whatever so what about all know web site like Facebook well on your newsfeed has a list of everyones post and then you can click either you know someone's profile or picture or something and then has details about the object so again it all comes down to two things a list of objects in details about one single object so I'm sure no matter what website you think of they always have the same patterns now on our website that we're making right now we're kind of doing the same thing the homepage is just a list of all over albums and it's going to be the cover photo and you know the artist stuff later on whenever we design it properly but it's basically a list of all of our albums then whenever we click one there's details about that individual item so the album logo and all the songs tomato tomahto so since django realize that people were just creating the same patterns over and over and over again why not help him out and speed up the process a little bit so just a heads-up before this tutorial I pretty much clean out everything in the index HTML in details HTML and I got rid of all the favoriting form because that's not the proper way to actually favorite songs that was just a little example so i pretty much stripped everything down except you know just displaying the bare basics like on the album name and you know the song titles in tomato tomahto so there you go just want to give you guys a heads up so now with that being said i'm actually going to go ahead and delete this so just go ahead and delete everything to do with favorites and actually let me go ahead and delete every sick thing inside views and I know you guys are extreme bike oh my god what are you doing we spent like 20 tutorials learn about those everything Hitler is deleted guys I promise like I said you get guys are gonna love me after this so instead of the way we've been making views before which are basically functions what we're going to do now is we're going to make something called a generic views so from Django . views import generic now we also need to import albums still from models and for album art so in this tutorial I'm just going to make two generic views oh sorry a black long alright so the first one is just going to be a list generically which is going to list all over elbows and the second one is going to be a detail generic view which is going to give us details about that individual album so it's going to be the exact same as before to the user but we're gonna Ray a lot less code so how do we make a generic view well instead of functions we actually use classes so for the home page since it's the next page i'm just going to say index view now the type of you we use we actually inherited so there are a couple different types of course in the strong and be teaching you guys about the list generic for you and also the detail generic for you i remember on the index page is just a list of all of our albums so we're actually going to inherit from generic list view all right so what we need to do now is the first thing we need to specify is what template were using so over in templates index.html of course we're using index HTML to display the album's so I'm just going to go ahead and write template name and set this equal to music / index.html so that just says whenever we get a list of all the albums plug them into this template right here pretty easy now there's only one other thing that we need to make in here and that is a query set function so basically we're going to say we're going to make a function called get query set and all this is going to do is we're going to query the database for whatever albums we want and in this example we'll just go ahead and get all of them so return album objects all guys you know what this is actually it this is all you need to do for this generic view now before i run this actually need to complete the rest of this code so that's all we need to do for the home page and let's go ahead and make the details vi ...