title
Python Django Tutorial: Full-Featured Web App Part 11 - Pagination

description
In this Python Django Tutorial, we will be learning how to use pagination so that we aren't pulling down too many posts at once. We will also learn how to create a page for posts created by a specific user. Let's get started... The code for this series can be found at: https://github.com/CoreyMSchafer/code_snippets/tree/master/Django_Blog Posts.json file: https://raw.githubusercontent.com/CoreyMSchafer/code_snippets/master/Django_Blog/snippets/posts.json ✅ Support My Channel Through Patreon: https://www.patreon.com/coreyms ✅ Become a Channel Member: https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join ✅ One-Time Contribution Through PayPal: https://goo.gl/649HFY ✅ Cryptocurrency Donations: Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33 Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot ✅ Corey's Public Amazon Wishlist http://a.co/inIyro1 ✅ Equipment I Use and Books I Recommend: https://www.amazon.com/shop/coreyschafer ▶️ You Can Find Me On: My Website - http://coreyms.com/ My Second Channel - https://www.youtube.com/c/coreymschafer Facebook - https://www.facebook.com/CoreyMSchafer Twitter - https://twitter.com/CoreyMSchafer Instagram - https://www.instagram.com/coreymschafer/ #Python #Django

detail
{'title': 'Python Django Tutorial: Full-Featured Web App Part 11 - Pagination', 'heatmap': [{'end': 224.792, 'start': 174.379, 'weight': 0.711}, {'end': 1112.97, 'start': 1086.997, 'weight': 0.702}, {'end': 1222.689, 'start': 1176.91, 'weight': 0.853}, {'end': 1446.296, 'start': 1398.036, 'weight': 0.74}, {'end': 1560.279, 'start': 1532.132, 'weight': 0.949}, {'end': 1654.814, 'start': 1612.205, 'weight': 0.732}, {'end': 1777.49, 'start': 1732.106, 'weight': 1}, {'end': 1914.435, 'start': 1881.584, 'weight': 0.754}, {'end': 2004.416, 'start': 1930.301, 'weight': 0.887}], 'summary': 'Tutorial series on python django covers adding pagination to limit posts, creating paginated pages, and importing approximately 25 posts, aiming to enhance performance and user experience. it demonstrates how to paginate posts in django using the paginator object and implementing pagination in python, and discusses adding pagination links to a django template for posts. the series also covers implementing pagination and page navigation in django, including accessing previous and nearby pages to easily navigate through the content, and custom user pages and paginator counts, troubleshooting pagination and user pages.', 'chapters': [{'end': 226.533, 'segs': [{'end': 34.112, 'src': 'embed', 'start': 0.229, 'weight': 0, 'content': [{'end': 1.25, 'text': "Hey there, how's it going everybody?", 'start': 0.229, 'duration': 1.021}, {'end': 2.07, 'text': 'In this video,', 'start': 1.61, 'duration': 0.46}, {'end': 8.274, 'text': "we're going to add a little more functionality to our site by adding some pagination so that we aren't pulling down too many posts at once.", 'start': 2.07, 'duration': 6.204}, {'end': 14.198, 'text': "And also we'll learn how to create a page of posts filtered by a specific user that is also going to be paginated.", 'start': 8.674, 'duration': 5.524}, {'end': 15.819, 'text': "So let's go ahead and get started.", 'start': 14.558, 'duration': 1.261}, {'end': 19.081, 'text': "So, first of all, since we're going to be working with pagination,", 'start': 16.279, 'duration': 2.802}, {'end': 23.924, 'text': "I'm going to take a second to add more posts to our current application from a variety of different users.", 'start': 19.081, 'duration': 4.843}, {'end': 27.807, 'text': 'That way we have enough posts to see this pagination in action.', 'start': 24.324, 'duration': 3.483}, {'end': 34.112, 'text': "Now I'm going to add some posts with a short script in the Django shell using a JSON file that I've prepared.", 'start': 28.327, 'duration': 5.785}], 'summary': 'Adding pagination for site functionality and filtering posts by user, with additional posts from various users.', 'duration': 33.883, 'max_score': 0.229, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ229.jpg'}, {'end': 116.558, 'src': 'embed', 'start': 90.999, 'weight': 3, 'content': [{'end': 95.642, 'text': "So I'm going to say Python manage.py and then shell.", 'start': 90.999, 'duration': 4.643}, {'end': 97.844, 'text': 'And again, this part is optional.', 'start': 96.423, 'duration': 1.421}, {'end': 102.367, 'text': "You can just manually add about 10 posts or so from the application that we've currently built.", 'start': 97.944, 'duration': 4.423}, {'end': 103.648, 'text': 'And that will be fine.', 'start': 102.768, 'duration': 0.88}, {'end': 108.572, 'text': "But to do this, if you want to do it this way, then within the shell, I'm going to make a couple of imports.", 'start': 104.008, 'duration': 4.564}, {'end': 110.293, 'text': "So I'll import JSON.", 'start': 108.772, 'duration': 1.521}, {'end': 113.536, 'text': 'And then I want to import my post model.', 'start': 110.694, 'duration': 2.842}, {'end': 116.558, 'text': 'So from blog.models, import JSON.', 'start': 113.876, 'duration': 2.682}], 'summary': 'Using python manage.py, add 10 posts manually or import from post model using json in the shell.', 'duration': 25.559, 'max_score': 90.999, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ90999.jpg'}, {'end': 224.792, 'src': 'heatmap', 'start': 174.379, 'weight': 0.711, 'content': [{'end': 186.202, 'text': 'And lastly, we will say that the author underscore ID is equal to post and we will access the user underscore ID of that object.', 'start': 174.379, 'duration': 11.823}, {'end': 190.443, 'text': "And those keys that I'm accessing there are just what I call those inside the JSON file.", 'start': 186.482, 'duration': 3.961}, {'end': 195.524, 'text': 'So on the next line, we will do a post dot save to save all of those.', 'start': 190.843, 'duration': 4.681}, {'end': 197.884, 'text': "Okay, and it looks like we didn't get any errors.", 'start': 196.244, 'duration': 1.64}, {'end': 198.605, 'text': "So that's good.", 'start': 198.025, 'duration': 0.58}, {'end': 200.645, 'text': 'Now I can exit out of the application.', 'start': 199.005, 'duration': 1.64}, {'end': 205.587, 'text': "And now we should have about 25 more posts or so now that we've run that short script.", 'start': 201.025, 'duration': 4.562}, {'end': 207.127, 'text': 'So now let me clear my screen.', 'start': 205.707, 'duration': 1.42}, {'end': 210.228, 'text': "Okay, so since we didn't get any errors, it should have saved all those properly.", 'start': 207.387, 'duration': 2.841}, {'end': 213.469, 'text': "So let's run our application and see what our homepage looks like.", 'start': 210.568, 'duration': 2.901}, {'end': 215.669, 'text': "So I'll say python manage.py run server.", 'start': 213.789, 'duration': 1.88}, {'end': 220.271, 'text': 'And now we can open this in the browser.', 'start': 217.97, 'duration': 2.301}, {'end': 222.031, 'text': 'So I will reload this.', 'start': 220.571, 'duration': 1.46}, {'end': 224.792, 'text': 'Okay, so now it looks like we have more posts to work with now.', 'start': 222.431, 'duration': 2.361}], 'summary': 'Successfully saved about 25 new posts, no errors encountered.', 'duration': 50.413, 'max_score': 174.379, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ174379.jpg'}], 'start': 0.229, 'title': 'Enhancing site functionality', 'summary': 'Covers adding pagination to limit posts, creating paginated pages, and importing approximately 25 posts to a django application, aiming to enhance performance and user experience.', 'chapters': [{'end': 52.206, 'start': 0.229, 'title': 'Adding pagination for posts', 'summary': "Focuses on adding pagination functionality to the site to limit the number of posts displayed at once and creating a paginated page of user-filtered posts, aiming to enhance the site's performance and user experience.", 'duration': 51.977, 'highlights': ['The chapter demonstrates adding pagination functionality to limit the number of posts displayed at once, improving site performance.', 'It also covers creating a paginated page of user-filtered posts, offering enhanced user experience.', 'The speaker plans to add more posts to the current application from various users, aiming to demonstrate the pagination in action and provide sufficient data for the example.', 'The speaker suggests an alternative method for those who want to follow along without adding more posts, stating that around 10 posts are sufficient to observe the pagination in action.']}, {'end': 226.533, 'start': 52.206, 'title': 'Adding posts to django application', 'summary': 'Discusses adding posts to a django application using a json file and django shell, demonstrating the process of importing data from the json file and adding it to the application, resulting in approximately 25 additional posts.', 'duration': 174.327, 'highlights': ['The chapter discusses adding posts to a Django application using a JSON file and Django shell, demonstrating the process of importing data from the JSON file and adding it to the application, resulting in approximately 25 additional posts.', 'The process involves importing the JSON and post model, opening the post.json file, using the JSON module to load it into Python, looping over the posts in the JSON file, creating a post for each entry, and saving the posts, resulting in the addition of about 25 more posts to the application.', 'The demonstration also includes running the application to verify the successful addition of the new posts and checking the homepage to confirm the availability of the added posts.']}], 'duration': 226.304, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ229.jpg', 'highlights': ['The chapter demonstrates adding pagination functionality to limit the number of posts displayed at once, improving site performance.', 'The chapter discusses adding posts to a Django application using a JSON file and Django shell, resulting in approximately 25 additional posts.', 'It also covers creating a paginated page of user-filtered posts, offering enhanced user experience.', 'The process involves importing the JSON and post model, opening the post.json file, using the JSON module to load it into Python, looping over the posts in the JSON file, creating a post for each entry, and saving the posts, resulting in the addition of about 25 more posts to the application.', 'The speaker plans to add more posts to the current application from various users, aiming to demonstrate the pagination in action and provide sufficient data for the example.']}, {'end': 602.714, 'segs': [{'end': 269.373, 'src': 'embed', 'start': 245.979, 'weight': 3, 'content': [{'end': 253.463, 'text': 'Now if these posts had images included in them and things like that, then loading them all in at once like this could really slow down our web page.', 'start': 245.979, 'duration': 7.484}, {'end': 263.589, 'text': 'It would be better if we could paginate this stuff so that we can load in a certain number of posts on one page and then display links at the bottom of the page to the other pages of posts.', 'start': 253.764, 'duration': 9.825}, {'end': 265.811, 'text': 'And Django makes this really easy for us.', 'start': 263.97, 'duration': 1.841}, {'end': 269.373, 'text': "So to do this, we're going to be working with a paginator object.", 'start': 266.171, 'duration': 3.202}], 'summary': 'Paginating posts with images can optimize web page speed using django paginator.', 'duration': 23.394, 'max_score': 245.979, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ245979.jpg'}, {'end': 357.375, 'src': 'embed', 'start': 312.469, 'weight': 1, 'content': [{'end': 318.233, 'text': 'So this will be the second post, this will be the third, this will be the fourth, and this will be the fifth.', 'start': 312.469, 'duration': 5.764}, {'end': 321.955, 'text': "Okay, so now we're going to create a paginator object out of these posts.", 'start': 318.613, 'duration': 3.342}, {'end': 325.718, 'text': 'And we are going to make this so that it is two posts per page.', 'start': 322.276, 'duration': 3.442}, {'end': 328.84, 'text': "So I'll say p is equal to paginator.", 'start': 326.018, 'duration': 2.822}, {'end': 333.943, 'text': 'And then we will pass in posts, and then a two for two posts per page.', 'start': 329.34, 'duration': 4.603}, {'end': 337.866, 'text': 'Okay, so we can pretend that the list of strings is actually a list of articles.', 'start': 334.424, 'duration': 3.442}, {'end': 340.428, 'text': 'And we just broke that up into two posts per page.', 'start': 338.166, 'duration': 2.262}, {'end': 342.489, 'text': 'So there should be three pages total.', 'start': 340.748, 'duration': 1.741}, {'end': 345.071, 'text': 'So with one value left on that third page.', 'start': 342.849, 'duration': 2.222}, {'end': 353.834, 'text': 'So if I say p dot num underscore pages, then we can see that we have three pages and if we wanted to loop over those pages,', 'start': 345.371, 'duration': 8.463}, {'end': 357.375, 'text': 'then we could use the page range method.', 'start': 353.834, 'duration': 3.541}], 'summary': 'Creating a paginator object with 2 posts per page, resulting in 3 pages total.', 'duration': 44.906, 'max_score': 312.469, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ312469.jpg'}, {'end': 538.456, 'src': 'embed', 'start': 498.016, 'weight': 0, 'content': [{'end': 503.517, 'text': "And now let me scroll down to the homepage, because this is one of the main ones that we're going to want to be paginating,", 'start': 498.016, 'duration': 5.501}, {'end': 507.298, 'text': 'because right now We have so many posts on that home page.', 'start': 503.517, 'duration': 3.781}, {'end': 515.422, 'text': "Now we're using class based views and we saw in the last video how this can save us a lot of code by creating a lot of stuff for us in the background.", 'start': 507.618, 'duration': 7.804}, {'end': 517.462, 'text': 'And pagination is no different.', 'start': 515.802, 'duration': 1.66}, {'end': 522.085, 'text': "We don't actually have to import that paginator class and create that ourselves.", 'start': 517.763, 'duration': 4.322}, {'end': 527.627, 'text': 'All we need to do is set an attribute on our list view called paginate by.', 'start': 522.445, 'duration': 5.182}, {'end': 533.852, 'text': 'So underneath ordering here, I can just say paginate underscore by is equal to two.', 'start': 528.047, 'duration': 5.805}, {'end': 538.456, 'text': "Now I'm just using two so that we can see what this looks like with a large number of pages.", 'start': 534.212, 'duration': 4.244}], 'summary': 'Using class-based views, set paginate_by attribute to 2 for homepage pagination.', 'duration': 40.44, 'max_score': 498.016, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ498016.jpg'}], 'start': 226.913, 'title': 'Implementing pagination in django and python', 'summary': 'Demonstrates how to paginate posts in django using the paginator object, allowing for efficient loading of a large number of posts while avoiding webpage slowdown. it also discusses the implementation of pagination in python, demonstrating the creation of pages of articles with specific content and highlighting the importance of navigation through previous and next pages.', 'chapters': [{'end': 333.943, 'start': 226.913, 'title': 'Implementing pagination in django', 'summary': 'Demonstrates how to paginate posts in django using the paginator object, allowing for efficient loading of a large number of posts while avoiding webpage slowdown, with the example showcasing the creation of a paginator object with two posts per page.', 'duration': 107.03, 'highlights': ['The chapter demonstrates how to paginate posts in Django using the paginator object, allowing for efficient loading of a large number of posts while avoiding webpage slowdown', 'The example showcases the creation of a paginator object with two posts per page', 'Django makes pagination easy through its paginator object']}, {'end': 456.704, 'start': 334.424, 'title': 'Pagination in python', 'summary': 'Discusses how to implement pagination in python, demonstrating the creation of 3 pages of articles with 2 articles per page and how to access specific pages and their content, emphasizing the importance of checking for previous and next pages for navigation.', 'duration': 122.28, 'highlights': ['It demonstrates the creation of 3 pages of articles with 2 articles per page, resulting in a total of 3 pages.', 'It shows how to access specific pages and their content, such as retrieving page 1 and its number, as well as listing the posts on that page.', "Emphasizes the importance of checking for previous and next pages for navigation, demonstrating the use of 'has_previous' and 'has_next' methods to determine the availability of previous and next pages."]}, {'end': 602.714, 'start': 456.704, 'title': 'Pagination in django views', 'summary': 'Explains how to use paginator objects in django views to paginate posts, showcasing the use of paginate_by attribute to achieve pagination functionality with a quantifiable example of displaying two posts per page.', 'duration': 146.01, 'highlights': ['The chapter provides a quick rundown of paginator objects, demonstrating the method p1.next_page_number() and its result of 2, highlighting the key concept of pagination functionality.', 'It explains the usage of paginate_by attribute in Django views, setting it to 2 to showcase pagination functionality with a quantifiable example of displaying two posts per page.', 'The chapter emphasizes the use of class-based views and the efficiency of creating background processes, such as pagination, without the need to import the paginator class and create it manually, showcasing the time-saving aspect of Django development.', 'It demonstrates the need for pagination on the homepage due to the large number of posts, highlighting the practical application of pagination in managing content.', 'It points out the initial limitation of not having links to other pages after implementing pagination and the need to address this issue, indicating the importance of providing navigation links for better user experience.']}], 'duration': 375.801, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ226913.jpg', 'highlights': ['The chapter emphasizes the use of class-based views and the efficiency of creating background processes, such as pagination, without the need to import the paginator class and create it manually, showcasing the time-saving aspect of Django development.', 'The example showcases the creation of a paginator object with two posts per page', 'It demonstrates the creation of 3 pages of articles with 2 articles per page, resulting in a total of 3 pages.', 'The chapter demonstrates how to paginate posts in Django using the paginator object, allowing for efficient loading of a large number of posts while avoiding webpage slowdown', 'It explains the usage of paginate_by attribute in Django views, setting it to 2 to showcase pagination functionality with a quantifiable example of displaying two posts per page.']}, {'end': 834.019, 'segs': [{'end': 646.483, 'src': 'embed', 'start': 602.714, 'weight': 0, 'content': [{'end': 606.757, 'text': 'so we had about five posts before and then i added 25 posts with that script.', 'start': 602.714, 'duration': 4.043}, {'end': 609.339, 'text': 'So I think now we should have around 30 posts.', 'start': 607.077, 'duration': 2.262}, {'end': 614.742, 'text': 'So there should be around 14 or 15 pages total since there are two posts per page.', 'start': 609.499, 'duration': 5.243}, {'end': 618.705, 'text': 'So let me try to go to page 14.', 'start': 615.203, 'duration': 3.502}, {'end': 620.266, 'text': 'We can see that there is a page 14.', 'start': 618.705, 'duration': 1.561}, {'end': 620.706, 'text': 'Let me try 15.', 'start': 620.266, 'duration': 0.44}, {'end': 627.511, 'text': 'Okay, so we must only have 28 posts because when I go to page 15, we get a 404.', 'start': 620.706, 'duration': 6.805}, {'end': 633.975, 'text': "And anytime you run out of pages and request a page that doesn't exist, then you will get a 404, which is good.", 'start': 627.511, 'duration': 6.464}, {'end': 642.581, 'text': 'Okay, so now all we need to do is add some links in our template so that we can actually navigate to these pages by clicking on them,', 'start': 634.816, 'duration': 7.765}, {'end': 646.483, 'text': "rather than manually typing them into the URL bar, like we're doing right now.", 'start': 642.581, 'duration': 3.902}], 'summary': '25 posts added, expecting 30 total. 14-15 pages with 2 posts per page. need to add links for page navigation.', 'duration': 43.769, 'max_score': 602.714, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ602714.jpg'}, {'end': 694.179, 'src': 'embed', 'start': 670.22, 'weight': 3, 'content': [{'end': 676.807, 'text': 'So that is within our blog app and templates and then the blog subdirectory and then home.html.', 'start': 670.22, 'duration': 6.587}, {'end': 683.394, 'text': 'Okay, so I think a good place for these pagination links will be right after our for loop where we loop over all of the posts.', 'start': 677.067, 'duration': 6.327}, {'end': 686.437, 'text': "So I'm going to go underneath our for loop here.", 'start': 683.814, 'duration': 2.623}, {'end': 689.678, 'text': 'and now we can put in our pagination logic.', 'start': 686.917, 'duration': 2.761}, {'end': 694.179, 'text': 'so the variables that got passed into our template are.', 'start': 689.678, 'duration': 4.501}], 'summary': 'Adding pagination links to the blog app template after looping over posts.', 'duration': 23.959, 'max_score': 670.22, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ670220.jpg'}, {'end': 834.019, 'src': 'embed', 'start': 807.022, 'weight': 6, 'content': [{'end': 817.308, 'text': "So I'll say class is equal to and we will make this look like a button and I will give this a button style of BTN outline dash info.", 'start': 807.022, 'duration': 10.286}, {'end': 818.829, 'text': "That's like a bluish style.", 'start': 817.408, 'duration': 1.421}, {'end': 822.291, 'text': "And also I'm going to give this a margin bottom of four.", 'start': 819.329, 'duration': 2.962}, {'end': 823.632, 'text': 'So MB dash four.', 'start': 822.371, 'duration': 1.261}, {'end': 828.215, 'text': 'okay and this will go a lot faster now that i can copy and paste some of these.', 'start': 824.292, 'duration': 3.923}, {'end': 834.019, 'text': "so now i'm going to copy this now, since this current page has a previous page,", 'start': 828.215, 'duration': 5.804}], 'summary': 'Styling class as button with btn outline info and margin bottom of 4.', 'duration': 26.997, 'max_score': 807.022, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ807022.jpg'}], 'start': 602.714, 'title': 'Paginating posts and adding navigation links', 'summary': 'Discusses adding 25 posts to the existing 5, resulting in a total of 30 posts. pagination is set to display 2 posts per page, leading to an expected 15 pages. however, an attempt to access page 15 results in a 404 error, indicating the actual presence of 28 posts only. additionally, it covers adding pagination links to a django template for posts.', 'chapters': [{'end': 646.483, 'start': 602.714, 'title': 'Adding posts and navigating pages', 'summary': 'Discusses the addition of 25 posts to the existing 5, resulting in a total of 30 posts. the pagination is set to display 2 posts per page, leading to an expected 15 pages. however, an attempt to access page 15 results in a 404 error, indicating the actual presence of 28 posts only. the need for adding navigation links to the template is recognized.', 'duration': 43.769, 'highlights': ['An attempt to access page 15 results in a 404 error, indicating the actual presence of 28 posts only.', 'Discussion about adding 25 posts to the existing 5, resulting in a total of 30 posts.', 'Pagination is set to display 2 posts per page, leading to an expected 15 pages.', 'Recognition of the need to add navigation links to the template for easier page access.']}, {'end': 834.019, 'start': 646.923, 'title': 'Paginating posts in a django template', 'summary': 'Covers adding pagination links to a django template for posts, including checking for pagination, creating links to go to the first and previous pages, and styling the pagination links.', 'duration': 187.096, 'highlights': ['The chapter covers adding pagination links to a Django template for posts, including checking for pagination, creating links to go to the first and previous pages, and styling the pagination links.', 'The view passes in the context needed to access page information in the template, and pagination logic is added after the for loop that loops over all the posts.', 'The pagination links are styled to look like buttons, with a bluish outline style and a margin bottom of four.']}], 'duration': 231.305, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ602714.jpg', 'highlights': ['An attempt to access page 15 results in a 404 error, indicating the actual presence of 28 posts only.', 'Discussion about adding 25 posts to the existing 5, resulting in a total of 30 posts.', 'Pagination is set to display 2 posts per page, leading to an expected 15 pages.', 'The chapter covers adding pagination links to a Django template for posts, including checking for pagination, creating links to go to the first and previous pages, and styling the pagination links.', 'Recognition of the need to add navigation links to the template for easier page access.', 'The view passes in the context needed to access page information in the template, and pagination logic is added after the for loop that loops over all the posts.', 'The pagination links are styled to look like buttons, with a bluish outline style and a margin bottom of four.']}, {'end': 1206.299, 'segs': [{'end': 902.081, 'src': 'embed', 'start': 880.347, 'weight': 0, 'content': [{'end': 888.712, 'text': "then we'll like to have links to a few pages before five and a few pages after five so that someone can easily navigate to pages nearby.", 'start': 880.347, 'duration': 8.365}, {'end': 893.515, 'text': "so i'm going to do a little trick here that i found online that allows us to do this.", 'start': 888.712, 'duration': 4.803}, {'end': 902.081, 'text': "so i am going to open up a code block here and this will be a for loop and we're going to loop over all of the pages in the paginator.", 'start': 893.515, 'duration': 8.566}], 'summary': 'Implementing code to create links for easy navigation to pages nearby.', 'duration': 21.734, 'max_score': 880.347, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ880347.jpg'}, {'end': 979.378, 'src': 'embed', 'start': 954.201, 'weight': 5, 'content': [{'end': 959.364, 'text': 'then that means that the current page should be displayed a little differently than the other pages.', 'start': 954.201, 'duration': 5.163}, {'end': 961.466, 'text': "So we'll just make this one a little darker.", 'start': 959.504, 'duration': 1.962}, {'end': 964.668, 'text': "So first of all, let's end this if statement.", 'start': 962.086, 'duration': 2.582}, {'end': 966.509, 'text': 'End if.', 'start': 965.308, 'duration': 1.201}, {'end': 972.213, 'text': 'And within this if statement, let me grab one of these other anchor tags to go off of.', 'start': 967.349, 'duration': 4.864}, {'end': 974.074, 'text': "So I'll grab that one and paste this in.", 'start': 972.353, 'duration': 1.721}, {'end': 979.378, 'text': "Now, first of all, since this is the current page, we don't want this to be an outline.", 'start': 974.594, 'duration': 4.784}], 'summary': 'Customize current page display with darker color and no outline.', 'duration': 25.177, 'max_score': 954.201, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ954201.jpg'}, {'end': 1044.914, 'src': 'embed', 'start': 1016.313, 'weight': 2, 'content': [{'end': 1020.676, 'text': 'And now we just want to print out a few pages that surround this current page.', 'start': 1016.313, 'duration': 4.363}, {'end': 1024.7, 'text': 'And to do this, we can use a couple of Django template filters.', 'start': 1020.997, 'duration': 3.703}, {'end': 1030.104, 'text': "So I'm going to put in an else statement here, and this is actually going to be an lf.", 'start': 1025.18, 'duration': 4.924}, {'end': 1034.167, 'text': "So I'll say lf the num that we are on through the loop.", 'start': 1030.444, 'duration': 3.723}, {'end': 1044.914, 'text': "if that is greater than the page underscore obj dot number and then I'm going to use a filter here.", 'start': 1035.829, 'duration': 9.085}], 'summary': 'Using django template filters to print surrounding pages.', 'duration': 28.601, 'max_score': 1016.313, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1016313.jpg'}, {'end': 1122.613, 'src': 'heatmap', 'start': 1067.007, 'weight': 3, 'content': [{'end': 1070.308, 'text': 'And we want to get all of the pages within the next three pages.', 'start': 1067.007, 'duration': 3.301}, {'end': 1078.012, 'text': "So I'll also say and, and I'm just going to copy this part here and paste that in.", 'start': 1070.609, 'duration': 7.403}, {'end': 1086.617, 'text': "And I'll say if the current number that we're on through the loop is less than the current page number and then add three,", 'start': 1078.273, 'duration': 8.344}, {'end': 1090.239, 'text': 'then we will also print out a link to that page as well.', 'start': 1086.997, 'duration': 3.242}, {'end': 1098.523, 'text': 'And we are very close to being done here, so that we can see what this actually looks like in the browser, because I know that this is confusing,', 'start': 1090.639, 'duration': 7.884}, {'end': 1101.184, 'text': "especially just to look at when you're not actually doing it.", 'start': 1098.523, 'duration': 2.661}, {'end': 1108.148, 'text': "So since this isn't the current page, I'm going to give this an outline of BTN outline info.", 'start': 1101.524, 'duration': 6.624}, {'end': 1109.048, 'text': 'And okay.', 'start': 1108.488, 'duration': 0.56}, {'end': 1112.97, 'text': 'finally, if the page has next pages,', 'start': 1109.048, 'duration': 3.922}, {'end': 1122.613, 'text': "then I'm also going to print out an option for them to go to just the next page and also the last page so that they can jump directly to the last page.", 'start': 1112.97, 'duration': 9.643}], 'summary': 'Code iterates through pages, prints links, and adds options for next/last page.', 'duration': 55.606, 'max_score': 1067.007, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1067007.jpg'}, {'end': 1138.878, 'src': 'embed', 'start': 1112.97, 'weight': 4, 'content': [{'end': 1122.613, 'text': "then I'm also going to print out an option for them to go to just the next page and also the last page so that they can jump directly to the last page.", 'start': 1112.97, 'duration': 9.643}, {'end': 1136.137, 'text': "so I'm going to copy this section up here because it's going to be fairly similar and after our for loop in here I'm going to paste that in and now we'll say if the current page object has next,", 'start': 1122.613, 'duration': 13.524}, {'end': 1138.878, 'text': "then we'll want to have a link to that next page.", 'start': 1136.137, 'duration': 2.741}], 'summary': 'Creating options for users to navigate to next and last page.', 'duration': 25.908, 'max_score': 1112.97, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1112970.jpg'}], 'start': 834.019, 'title': 'Implementing pagination and page navigation in django', 'summary': 'Covers implementing pagination and page navigation in django, including accessing previous and nearby pages to easily navigate through the content. it explains the logic for displaying the current page and surrounding pages within a loop, including conditional formatting and the use of django template filters. additionally, the process of generating pagination links for a web page is explained, including adding links for previous and next pages within a specified range, and options for jumping directly to the last page, with a focus on implementing if statements for each condition.', 'chapters': [{'end': 927.932, 'start': 834.019, 'title': 'Pagination and page navigation in django', 'summary': 'Covers implementing pagination and page navigation in django, including accessing previous and nearby pages to easily navigate through the content.', 'duration': 93.913, 'highlights': ['Implementing pagination and page navigation in Django, including accessing previous and nearby pages to easily navigate through the content.', 'Using a code block with a for loop to iterate over all pages in the paginator object to display nearby pages for easy navigation.']}, {'end': 1044.914, 'start': 927.932, 'title': 'Pagination display logic', 'summary': 'Explains the logic for displaying the current page and surrounding pages within a loop, including conditional formatting and the use of django template filters.', 'duration': 116.982, 'highlights': ['The current page is identified within the loop by checking if the page number is equal to the current iteration, and it is displayed differently with a darker shade.', 'The current page is displayed as a solid button with its number and does not operate as a link to page one or any specific page.', 'The logic for displaying pages surrounding the current page involves using Django template filters, specifically checking if the page number in the loop is greater than the current page number.']}, {'end': 1206.299, 'start': 1044.914, 'title': 'Pagination and link generation', 'summary': 'Explains the process of generating pagination links for a web page, including adding links for previous and next pages within a specified range, and options for jumping directly to the last page, with a focus on implementing if statements for each condition.', 'duration': 161.385, 'highlights': ['Implementing if statements for adding links to previous and next pages within a specified range', 'Including options for users to jump directly to the last page', 'Challenges and need for practical demonstration']}], 'duration': 372.28, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ834019.jpg', 'highlights': ['Implementing pagination and page navigation in Django, including accessing previous and nearby pages to easily navigate through the content.', 'Using a code block with a for loop to iterate over all pages in the paginator object to display nearby pages for easy navigation.', 'The logic for displaying pages surrounding the current page involves using Django template filters, specifically checking if the page number in the loop is greater than the current page number.', 'Implementing if statements for adding links to previous and next pages within a specified range', 'Including options for users to jump directly to the last page', 'The current page is identified within the loop by checking if the page number is equal to the current iteration, and it is displayed differently with a darker shade.']}, {'end': 1642.723, 'segs': [{'end': 1261.706, 'src': 'embed', 'start': 1228.255, 'weight': 0, 'content': [{'end': 1230.157, 'text': 'So we are currently on page one.', 'start': 1228.255, 'duration': 1.902}, {'end': 1232.539, 'text': 'So we can see that that is styled differently.', 'start': 1230.437, 'duration': 2.102}, {'end': 1234.121, 'text': 'That is just a solid button.', 'start': 1232.599, 'duration': 1.522}, {'end': 1236.844, 'text': "And page one doesn't have any previous pages.", 'start': 1234.521, 'duration': 2.323}, {'end': 1241.669, 'text': "So we can see that we don't have a link to go to a previous page or the very first page.", 'start': 1237.184, 'duration': 4.485}, {'end': 1248.615, 'text': 'But and then it also puts out page two and three since page two and three are close to one.', 'start': 1242.069, 'duration': 6.546}, {'end': 1255.681, 'text': 'Now, we also have a next link here that will just take us to page two or we can go to the very last page by clicking on last.', 'start': 1248.915, 'duration': 6.766}, {'end': 1261.706, 'text': "So if I just go to page three, actually, let me go to like page seven or so to where we're right in the middle.", 'start': 1256.061, 'duration': 5.645}], 'summary': 'The document has styled buttons, lacks previous page links, and allows navigation to specific pages.', 'duration': 33.451, 'max_score': 1228.255, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1228255.jpg'}, {'end': 1390.847, 'src': 'embed', 'start': 1366.044, 'weight': 1, 'content': [{'end': 1371.785, 'text': "so let's build a route that will display only the post from that particular user when you click on that link.", 'start': 1366.044, 'duration': 5.741}, {'end': 1376.25, 'text': 'And if the user has a bunch of posts, then we want those to be paginated as well.', 'start': 1372.265, 'duration': 3.985}, {'end': 1381.456, 'text': "So to do that, it's going to be very similar to our homepage list view that we currently have.", 'start': 1376.69, 'duration': 4.766}, {'end': 1385.3, 'text': "But we're just going to filter that list by that user.", 'start': 1381.696, 'duration': 3.604}, {'end': 1388.064, 'text': "So let's go ahead and see what this looks like.", 'start': 1385.601, 'duration': 2.463}, {'end': 1390.847, 'text': "So I'm going to open up our views.", 'start': 1388.424, 'duration': 2.423}], 'summary': 'Build a route to display posts by a user with pagination.', 'duration': 24.803, 'max_score': 1366.044, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1366044.jpg'}, {'end': 1446.296, 'src': 'heatmap', 'start': 1398.036, 'weight': 0.74, 'content': [{'end': 1402.301, 'text': "So I'm going to copy that and right underneath it, I will paste that in.", 'start': 1398.036, 'duration': 4.265}, {'end': 1406.827, 'text': "And now let's make a view called user post list view.", 'start': 1402.842, 'duration': 3.985}, {'end': 1413.953, 'text': "And for the template name here, Let's just create a template called user underscore post dot HTML.", 'start': 1407.307, 'duration': 6.646}, {'end': 1417.676, 'text': 'So currently this will still list all of the posts from our post model.', 'start': 1414.233, 'duration': 3.443}, {'end': 1422.52, 'text': 'But we want to add a filter to this that only gets the post from a certain user.', 'start': 1417.996, 'duration': 4.524}, {'end': 1425.582, 'text': 'And that is going to come directly from the URL.', 'start': 1422.94, 'duration': 2.642}, {'end': 1432.688, 'text': "So when we create a new URL pattern for this, we'll specify the username and the URL path itself.", 'start': 1425.983, 'duration': 6.705}, {'end': 1436.211, 'text': "So we'll set that whenever we create the URL pattern here in a second.", 'start': 1433.068, 'duration': 3.143}, {'end': 1441.033, 'text': "But for now, let's just assume that we have a username variable passed into the URL.", 'start': 1436.551, 'duration': 4.482}, {'end': 1446.296, 'text': 'So, in order to modify the query set that this list view returns,', 'start': 1441.694, 'duration': 4.602}], 'summary': 'Creating a view to filter posts by username in a django app.', 'duration': 48.26, 'max_score': 1398.036, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1398036.jpg'}, {'end': 1515.086, 'src': 'embed', 'start': 1489.24, 'weight': 2, 'content': [{'end': 1493.943, 'text': 'And as the name implies there, it will get an object from the database if that object exists.', 'start': 1489.24, 'duration': 4.703}, {'end': 1497.325, 'text': "And if it doesn't exist, then it'll just return a 404.", 'start': 1494.063, 'duration': 3.262}, {'end': 1501.07, 'text': 'So first we need to import that and that is from Django shortcuts.', 'start': 1497.325, 'duration': 3.745}, {'end': 1506.197, 'text': "So we'll just go up to the top here and we're already importing render from Django shortcuts.", 'start': 1501.41, 'duration': 4.787}, {'end': 1513.886, 'text': 'So now we just need to also import get underscore object underscore or underscore 404.', 'start': 1506.537, 'duration': 7.349}, {'end': 1515.086, 'text': "So now let's go back down.", 'start': 1513.886, 'duration': 1.2}], 'summary': 'Code fetches object from database and returns 404 if not found.', 'duration': 25.846, 'max_score': 1489.24, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1489240.jpg'}, {'end': 1560.279, 'src': 'heatmap', 'start': 1532.132, 'weight': 0.949, 'content': [{'end': 1536.073, 'text': 'It is from django.contrib.auth.models import user.', 'start': 1532.132, 'duration': 3.941}, {'end': 1542.178, 'text': 'user and now we can use those imports to grab the user.', 'start': 1538.994, 'duration': 3.184}, {'end': 1549.207, 'text': 'so down here, in the method that we just created, that is right.', 'start': 1542.178, 'duration': 7.029}, {'end': 1560.279, 'text': 'here, get query set, we can say user is equal to get object or 404, And we want to get this object from that user model.', 'start': 1549.207, 'duration': 11.072}], 'summary': 'Using django.contrib.auth.models, we can grab the user object from the created method.', 'duration': 28.147, 'max_score': 1532.132, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1532132.jpg'}], 'start': 1206.619, 'title': 'Implementing user post list view', 'summary': 'Covers implementing pagination, adjusting post per page to 5, creating a user post list view, and retrieving users and filtering posts by username using django shortcuts and model imports.', 'chapters': [{'end': 1345.98, 'start': 1206.619, 'title': 'Pagination implementation and post per page adjustment', 'summary': 'Demonstrates the implementation of pagination with dynamic page links and explains the adjustment of post per page to five, showcasing the functionality with a demonstration.', 'duration': 139.361, 'highlights': ['The pagination implementation allows for dynamic page links based on the current page and nearby pages, displaying a solid button for the current page and appropriate links for previous and next pages.', 'The demonstration showcases the printing of nearby pages within three pages previous and three pages next, with the ability to navigate to the first, last, and specific pages, as well as the adjustment of post per page to five.']}, {'end': 1464.325, 'start': 1345.98, 'title': 'Creating user post list view', 'summary': 'Discusses creating a user post list view, which aims to display only the posts from a particular user when clicked on the username link, with the ability to paginate multiple posts, and involves modifying the query set in the views.', 'duration': 118.345, 'highlights': ['Creating a view to display only the posts from a particular user with pagination.', 'Modifying the query set in the views to filter posts by a certain user.', 'Copying the post list view and creating a new view called user post list view with a template named user_post.html.']}, {'end': 1642.723, 'start': 1464.565, 'title': 'Retrieve user and filter posts', 'summary': 'Focuses on retrieving a user from the database based on the username obtained from the url and filtering posts by the retrieved user, utilizing django shortcuts like get_object_or_404 and model imports like user. the chapter also highlights the process of overriding a query in a listview and applying an order by clause directly to the query.', 'duration': 178.158, 'highlights': ['The chapter highlights the use of Django shortcuts, specifically get_object_or_404, for retrieving a user from the database, ensuring that a 404 error is returned if the user does not exist.', 'It emphasizes the necessity of importing the user model from django.contrib.auth.models and utilizing the imported user for database operations.', 'The chapter also underscores the process of overriding a query in a ListView, removing the previous order by clause, and directly applying a new order by clause to the query.']}], 'duration': 436.104, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1206619.jpg', 'highlights': ['The pagination implementation allows for dynamic page links based on the current page and nearby pages, displaying a solid button for the current page and appropriate links for previous and next pages.', 'Creating a view to display only the posts from a particular user with pagination.', 'The chapter highlights the use of Django shortcuts, specifically get_object_or_404, for retrieving a user from the database, ensuring that a 404 error is returned if the user does not exist.']}, {'end': 1861.112, 'segs': [{'end': 1665.422, 'src': 'embed', 'start': 1643.043, 'weight': 1, 'content': [{'end': 1654.814, 'text': 'So returning that filtered post query and our get query set method is what will limit our posts on that page to that specific user that has their username as the parameter in the URL.', 'start': 1643.043, 'duration': 11.771}, {'end': 1665.422, 'text': "Okay, so now let's actually create that path in our URL patterns that contains the username parameter So we want to open our blog URLs.", 'start': 1655.755, 'duration': 9.667}], 'summary': 'Method limits posts by specific user with username parameter in url.', 'duration': 22.379, 'max_score': 1643.043, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1643043.jpg'}, {'end': 1777.49, 'src': 'heatmap', 'start': 1716.736, 'weight': 2, 'content': [{'end': 1718.839, 'text': 'So we can say that this is going to be a string.', 'start': 1716.736, 'duration': 2.103}, {'end': 1725.502, 'text': 'Okay, and the view that we want to handle this path is going to be that user post list view.', 'start': 1719.179, 'duration': 6.323}, {'end': 1731.726, 'text': "And then the name that we want to use here, let's just use user dash post.", 'start': 1726.183, 'duration': 5.543}, {'end': 1735.588, 'text': 'Okay, so now we have the view and we have the URL pattern.', 'start': 1732.106, 'duration': 3.482}, {'end': 1737.889, 'text': "Now let's just create that template.", 'start': 1735.988, 'duration': 1.901}, {'end': 1744.371, 'text': 'So we said in our view that we would name that template user underscore post dot HTML.', 'start': 1738.249, 'duration': 6.122}, {'end': 1752.514, 'text': "So within our blog templates, I'm going to create a new template here and call this user underscore post dot HTML.", 'start': 1744.771, 'duration': 7.743}, {'end': 1755.095, 'text': 'And this is going to be very similar to our homepage.', 'start': 1752.854, 'duration': 2.241}, {'end': 1757.496, 'text': "So I'm just going to use that as the starting point.", 'start': 1755.395, 'duration': 2.101}, {'end': 1761.097, 'text': "So I'm going to open our homepage here and copy that.", 'start': 1757.816, 'duration': 3.281}, {'end': 1768.723, 'text': 'And we want to keep all that pagination logic in there too because our user post page can be paginated as well if they have enough posts.', 'start': 1761.517, 'duration': 7.206}, {'end': 1777.49, 'text': "So the difference here between this and the home page will be that I'll add a heading at the top specifying that this is this user's page.", 'start': 1769.163, 'duration': 8.327}], 'summary': 'Creating a user post list view with a new template.', 'duration': 44.361, 'max_score': 1716.736, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1716736.jpg'}, {'end': 1861.112, 'src': 'embed', 'start': 1811.407, 'weight': 0, 'content': [{'end': 1813.868, 'text': "So we'll put in our curly brackets here.", 'start': 1811.407, 'duration': 2.461}, {'end': 1815.569, 'text': 'Now, how can we do this?', 'start': 1814.288, 'duration': 1.281}, {'end': 1830.274, 'text': 'So one way that we can do this would be to get the current paginator page so page underscore obj and then get the paginator object from there and then access the dot count attribute.', 'start': 1816.009, 'duration': 14.265}, {'end': 1837.877, 'text': 'And the dot count attribute will return the total number of objects along all of the pages in that paginator.', 'start': 1830.494, 'duration': 7.383}, {'end': 1843.921, 'text': 'So if you have, you know, 30 pages of two objects, then this will return a count of 60.', 'start': 1838.277, 'duration': 5.644}, {'end': 1849.024, 'text': 'Okay So with that in place, let me also just give this a quick class here.', 'start': 1843.921, 'duration': 5.103}, {'end': 1854.127, 'text': "So I'll set a class equal to, and I just want to give this a margin bottom.", 'start': 1849.144, 'duration': 4.983}, {'end': 1855.528, 'text': "So I'll say MB dash class.", 'start': 1854.147, 'duration': 1.381}, {'end': 1861.112, 'text': 'Now the post for loop will stay mostly the same, but a couple of things are going to change.', 'start': 1856.529, 'duration': 4.583}], 'summary': 'Accessing paginator count attribute to get total objects across pages.', 'duration': 49.705, 'max_score': 1811.407, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1811407.jpg'}], 'start': 1643.043, 'title': 'Custom user pages and paginator counts', 'summary': 'Details the process of creating user-specific post pages and retrieving the total number of objects across all pages in a paginator, with a specific example of obtaining a count of 60 for 30 pages of two objects and making minor css adjustments.', 'chapters': [{'end': 1810.546, 'start': 1643.043, 'title': 'Creating user-specific post page', 'summary': "Details the process of creating a user-specific post page, including defining url patterns, views, and templates, and specifying the user's username parameter with the total number of posts.", 'duration': 167.503, 'highlights': ["Defining URL patterns and specifying the user's username parameter", 'Creating a view to handle the user-specific post page', 'Defining a template for the user-specific post page']}, {'end': 1861.112, 'start': 1811.407, 'title': 'Paginator page count', 'summary': 'Explains how to retrieve the total number of objects across all pages in a paginator by accessing the dot count attribute, providing a clear example of obtaining a count of 60 for 30 pages of two objects, and making minor css adjustments.', 'duration': 49.705, 'highlights': ['Accessing the dot count attribute of the paginator object provides the total number of objects across all pages, demonstrated by obtaining a count of 60 for 30 pages of two objects.', 'Demonstrates making a minor CSS adjustment by setting a margin bottom for the class.']}], 'duration': 218.069, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1643043.jpg', 'highlights': ['Accessing the dot count attribute of the paginator object provides the total number of objects across all pages, demonstrated by obtaining a count of 60 for 30 pages of two objects.', "Defining URL patterns and specifying the user's username parameter", 'Creating a view to handle the user-specific post page', 'Defining a template for the user-specific post page', 'Demonstrates making a minor CSS adjustment by setting a margin bottom for the class.']}, {'end': 2207.937, 'segs': [{'end': 1914.435, 'src': 'heatmap', 'start': 1861.252, 'weight': 3, 'content': [{'end': 1869.878, 'text': 'So we can actually set the href for the user now to go to the user post route that we are creating right now.', 'start': 1861.252, 'duration': 8.626}, {'end': 1876.663, 'text': "So right here is where we're printing out the post author and we can see that this link is dead.", 'start': 1870.338, 'duration': 6.325}, {'end': 1881.224, 'text': "So let's actually let this link to this user's page.", 'start': 1877.123, 'duration': 4.101}, {'end': 1891.348, 'text': "So we will put in a code block here, and we'll say that this is a URL, and we called that URL user-posts.", 'start': 1881.584, 'duration': 9.764}, {'end': 1898.57, 'text': 'And the username that we want to link to for this route is going to be the username of this author.', 'start': 1891.668, 'duration': 6.902}, {'end': 1905.272, 'text': 'So we will say post.author.username and save that.', 'start': 1898.93, 'duration': 6.342}, {'end': 1909.713, 'text': "And we're actually going to have to change that in our home and post template as well.", 'start': 1905.732, 'duration': 3.981}, {'end': 1914.435, 'text': "And I know that having repeated code in multiple locations isn't the best practice,", 'start': 1910.114, 'duration': 4.321}], 'summary': "Setting the href for user post route and updating username link to user's page.", 'duration': 30.096, 'max_score': 1861.252, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1861252.jpg'}, {'end': 2006.037, 'src': 'heatmap', 'start': 1914.435, 'weight': 4, 'content': [{'end': 1919.817, 'text': "but we'll fix that in a future video when we see how to use sub templates for repeated sections like this.", 'start': 1914.435, 'duration': 5.382}, {'end': 1922.178, 'text': "But for now, let's just finish this up.", 'start': 1920.257, 'duration': 1.921}, {'end': 1929.02, 'text': 'So we need to add those links to this user route to our homepage and our post detail template as well.', 'start': 1922.538, 'duration': 6.482}, {'end': 1930.201, 'text': "So let's do that.", 'start': 1929.38, 'duration': 0.821}, {'end': 1932.761, 'text': "So I'm just going to copy this URL here.", 'start': 1930.301, 'duration': 2.46}, {'end': 1935.803, 'text': 'So the beginning of this code block to the end.', 'start': 1932.922, 'duration': 2.881}, {'end': 1941.925, 'text': 'And I know that this post author has a link in the homepage as well.', 'start': 1936.463, 'duration': 5.462}, {'end': 1947.467, 'text': "So in our home template, I'm going to scroll up to where we have the link for this post author.", 'start': 1942.265, 'duration': 5.202}, {'end': 1949.247, 'text': 'And I will just post that in.', 'start': 1947.847, 'duration': 1.4}, {'end': 1954.069, 'text': 'So a URL to user post using that post.author.username.', 'start': 1949.647, 'duration': 4.422}, {'end': 1955.85, 'text': 'and save that.', 'start': 1954.769, 'duration': 1.081}, {'end': 1960.272, 'text': 'And we also want to set this in the post detail template as well.', 'start': 1956.29, 'duration': 3.982}, {'end': 1963.073, 'text': "So we can see here, this is where we're printing out the author.", 'start': 1960.652, 'duration': 2.421}, {'end': 1964.614, 'text': 'That link is currently dead.', 'start': 1963.433, 'duration': 1.181}, {'end': 1969.716, 'text': 'We will paste that in for the user post, post.author.username.', 'start': 1964.934, 'duration': 4.782}, {'end': 1971.797, 'text': 'And actually, I almost made a mistake here.', 'start': 1970.076, 'duration': 1.721}, {'end': 1974.518, 'text': 'This is in the post detail template.', 'start': 1972.417, 'duration': 2.101}, {'end': 1976.239, 'text': 'Remember, this is called object.', 'start': 1974.538, 'duration': 1.701}, {'end': 1978.78, 'text': "So let's say object.author.username.", 'start': 1976.419, 'duration': 2.361}, {'end': 1981.261, 'text': "Okay, so with those changes, let's save everything.", 'start': 1979.18, 'duration': 2.081}, {'end': 1986.184, 'text': 'And then open this in the browser and try to see posts created by a single user.', 'start': 1981.641, 'duration': 4.543}, {'end': 1991.107, 'text': 'So I will save all of that and check our dev server.', 'start': 1986.564, 'duration': 4.543}, {'end': 1992.268, 'text': 'Dev server is running.', 'start': 1991.167, 'duration': 1.101}, {'end': 1994.79, 'text': "So now let's reload our homepage here.", 'start': 1992.648, 'duration': 2.142}, {'end': 2000.234, 'text': "And now let's click on this QueryMS user and see if we can go to their specific page.", 'start': 1995.15, 'duration': 5.084}, {'end': 2004.416, 'text': 'So now we can see this says posts by QueryMS, 28 total.', 'start': 2000.594, 'duration': 3.822}, {'end': 2006.037, 'text': "So let's see if that's right.", 'start': 2004.797, 'duration': 1.24}], 'summary': 'Updating homepage and post detail template with user links.', 'duration': 91.602, 'max_score': 1914.435, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1914435.jpg'}, {'end': 2032.35, 'src': 'embed', 'start': 2006.098, 'weight': 1, 'content': [{'end': 2010.28, 'text': "If I go to the last page here, Okay, so actually this isn't right right now.", 'start': 2006.098, 'duration': 4.182}, {'end': 2012.301, 'text': 'Something is not returning properly.', 'start': 2010.38, 'duration': 1.921}, {'end': 2017.683, 'text': 'I think 28 posts is the total number of posts that we have on the entire blog right now.', 'start': 2012.841, 'duration': 4.842}, {'end': 2021.405, 'text': 'And plus we can see that this is returning test user posts as well.', 'start': 2018.044, 'duration': 3.361}, {'end': 2024.106, 'text': 'This should only be posts from this specific user.', 'start': 2021.725, 'duration': 2.381}, {'end': 2030.77, 'text': "So it's getting the username correctly from the URL, but something must be wrong with the query set that we're getting back.", 'start': 2024.407, 'duration': 6.363}, {'end': 2032.35, 'text': "So let's go check that.", 'start': 2031.09, 'duration': 1.26}], 'summary': 'There are 28 total blog posts, but the query is returning test user posts incorrectly.', 'duration': 26.252, 'max_score': 2006.098, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ2006098.jpg'}, {'end': 2073.902, 'src': 'embed', 'start': 2047.288, 'weight': 2, 'content': [{'end': 2050.752, 'text': 'And so if I save that, that should solve our problem.', 'start': 2047.288, 'duration': 3.464}, {'end': 2051.614, 'text': 'So sorry about that.', 'start': 2050.853, 'duration': 0.761}, {'end': 2058.956, 'text': "So now let me go back to our page and let me go back or I'll just click on this user again.", 'start': 2052.074, 'duration': 6.882}, {'end': 2062.818, 'text': 'So now if I click on this user, well, now it looks like we have another error here.', 'start': 2059.237, 'duration': 3.581}, {'end': 2067.1, 'text': 'So this says query set object has no attribute order a buy.', 'start': 2062.958, 'duration': 4.142}, {'end': 2068.36, 'text': 'So I spelled order by wrong.', 'start': 2067.159, 'duration': 1.201}, {'end': 2069.4, 'text': 'Sorry about this, guys.', 'start': 2068.661, 'duration': 0.739}, {'end': 2071.802, 'text': "I usually don't make this many mistakes.", 'start': 2069.561, 'duration': 2.241}, {'end': 2073.902, 'text': 'So in the views here.', 'start': 2072.542, 'duration': 1.36}], 'summary': 'Fixing errors in the code to solve problem.', 'duration': 26.614, 'max_score': 2047.288, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ2047288.jpg'}, {'end': 2178.248, 'src': 'embed', 'start': 2133.016, 'weight': 0, 'content': [{'end': 2136.818, 'text': 'So that should be two pages and it is two pages of five.', 'start': 2133.016, 'duration': 3.802}, {'end': 2141.181, 'text': "And also let's make sure that we get a 404 page for users that don't exist.", 'start': 2137.438, 'duration': 3.743}, {'end': 2148.527, 'text': "So if I go to just some gibberish page here, then we can see that we get a 404 for a user that doesn't exist.", 'start': 2141.461, 'duration': 7.066}, {'end': 2149.848, 'text': 'So that is good.', 'start': 2148.707, 'duration': 1.141}, {'end': 2156.494, 'text': 'So we can see that these user pages are working well and that we have pagination working for the posts on these pages also.', 'start': 2150.249, 'duration': 6.245}, {'end': 2159.456, 'text': 'Okay, so I think that is going to do it for this video.', 'start': 2157.294, 'duration': 2.162}, {'end': 2164.18, 'text': 'I hope that now you have a good idea for how you can get pagination working on your website.', 'start': 2159.796, 'duration': 4.384}, {'end': 2169.523, 'text': 'and the different ways in which you can create the links and handle the logic for those in your application.', 'start': 2164.64, 'duration': 4.883}, {'end': 2178.248, 'text': 'Also, we learned how to create new list views with custom filtered queries and created a useful route for posts written by specific users.', 'start': 2170.163, 'duration': 8.085}], 'summary': 'Pagination and user pages are working well. 404 page for non-existent users is also implemented.', 'duration': 45.232, 'max_score': 2133.016, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ2133016.jpg'}], 'start': 1861.252, 'title': 'Troubleshooting pagination and user pages', 'summary': 'Covers troubleshooting pagination and user pages, including correcting query set errors, implementing pagination, and creating user-specific post views, with specific examples and quantifiable data.', 'chapters': [{'end': 2024.106, 'start': 1861.252, 'title': 'Setting user post routes', 'summary': "Discusses setting user post routes, linking user's page with the post author's username, and resolving issues with the total number of user posts being displayed on the blog.", 'duration': 162.854, 'highlights': ["The chapter discusses setting user post routes, linking user's page with the post author's username, and resolving issues with the total number of user posts being displayed on the blog.", "The user post route is created to link to the user's page, using the post author's username, resulting in a total of 28 posts displayed.", "The link to the user's page is added to the homepage and post detail template, with plans to optimize code repetition using sub templates in the future."]}, {'end': 2207.937, 'start': 2024.407, 'title': 'Troubleshooting pagination and user pages', 'summary': 'Covers troubleshooting pagination and user pages, including correcting query set errors, implementing pagination, and creating user-specific post views, with specific examples and quantifiable data.', 'duration': 183.53, 'highlights': ['Implemented pagination for posts, with 3 pages of 5 posts each, totaling 15, and 2 pages of 5 posts for a specific user, totaling 10.', "Corrected query set errors by changing 'get query set' to 'get_query_set' and fixing misspelled 'order by', resolving the issues with the user pages.", 'Discussed creating new list views with custom filtered queries and handling logic for pagination, providing practical examples and application insights.']}], 'duration': 346.685, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/acOktTcTVEQ/pics/acOktTcTVEQ1861252.jpg', 'highlights': ['Implemented pagination for posts, with 3 pages of 5 posts each, totaling 15, and 2 pages of 5 posts for a specific user, totaling 10.', "The user post route is created to link to the user's page, using the post author's username, resulting in a total of 28 posts displayed.", "Corrected query set errors by changing 'get query set' to 'get_query_set' and fixing misspelled 'order by', resolving the issues with the user pages.", "The chapter discusses setting user post routes, linking user's page with the post author's username, and resolving issues with the total number of user posts being displayed on the blog.", "The link to the user's page is added to the homepage and post detail template, with plans to optimize code repetition using sub templates in the future.", 'Discussed creating new list views with custom filtered queries and handling logic for pagination, providing practical examples and application insights.']}], 'highlights': ['The chapter demonstrates adding pagination functionality to limit the number of posts displayed at once, improving site performance.', 'The chapter emphasizes the use of class-based views and the efficiency of creating background processes, such as pagination, without the need to import the paginator class and create it manually, showcasing the time-saving aspect of Django development.', 'Accessing the dot count attribute of the paginator object provides the total number of objects across all pages, demonstrated by obtaining a count of 60 for 30 pages of two objects.', 'The pagination implementation allows for dynamic page links based on the current page and nearby pages, displaying a solid button for the current page and appropriate links for previous and next pages.', 'The chapter covers adding pagination links to a Django template for posts, including checking for pagination, creating links to go to the first and previous pages, and styling the pagination links.']}