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

preview_player
Показать описание
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:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python #Django
Рекомендации по теме
Комментарии
Автор

Corey: "And Django makes this easy for us."
Me: "No, you make this easy for us :)"

riturajjain
Автор

Corey, there is a serious lack of quality Django tutorials out there. You are the only one pumping them out. Your series is incredible. I know you must be busy with so many project ideas already, but could you try extending this series into an advanced series next? I feel like I've learned a lot, but I would like to see you tinker around with the styling, or integrating new apps from Django Packages. I still don't feel fully confident in straying off the path you've laid out for us. I'm sure there are many others like me who would love to see more examples of customization now. I also looked into Mezzanine and Wagtail as CMS options, but again, there are very few tutorials on either of those platforms either. If you're ever looking for other ideas for further series, maybe one on using a CMS would be cool too :). You're the best man, and I'm going to forever point people looking to learn python, to your YouTube.

idugi
Автор

I appreciate that you don't cut out when you do mistakes. I think it's important for beginners like me to see how you debug them and that even a professional like you can have a typo. Great videos. Thanks a lot!

AnthonySherrill
Автор

I really enjoy how you not only show how to do things, but explain some of the processes behind the operations. If gives inspiration for other creative ideas and uses.

SliderHavoc
Автор

Probably the best tutorials on Django. Thanks-a-lot Corey, your content is not less than magic simple, detailed and obviously well explained. Thanks a-lot.

ankitpandey
Автор

I really like it when Corey fids a mistake and fix it in seconds
I spend hours debugging an indentation

AymenLagha
Автор

Corey. Your tutorials are premium quality. Anyone who says otherwise is just insane. I would love it if you can make a tutorial on how you learn(Especially going through documentation) because I don't know how you dig out some deep concepts but I would love to learn.

mrchike
Автор

For those that are having trouble with adding the extra posts from the posts.json, make sure you have the user id exists for id 1 and id 2 and you did not delete that user.
You can check with this command in the shell:

from django.contrib.auth.models import User
User.objects.get(id=1) # make sure this returns a user
User.objects.get(id=2) # make sure this returns a user

If no user is returned, make a new user with the <missing id>:

Hope this helps. Corey is the bomb.

michaelng
Автор

Honestly Bro! I was doing your django series after that I took udemy course and realised that first two projects were real shit. Got only 2 to 3 different pieces of information from those udemy videos. Did your series again and understood the concepts in more clearity.
You are the only one out there carrying this quality stuff out there.
There is serious lack of quality stuff out there. It would be very helpful if you could make a course on DJANGO REST FRAMEWORK. Need guidance in that part.
Thank you for everything you are doing for us and we also make sure that we will watch all the ads and visit the pages as a support to this channel.
Love for your dog from India.

carekaro
Автор

I would love to see a part 2 of this series

bentwite
Автор

Hey, am getting anl template syntax error at line 24, time: 20:02.
Could not parse remainder '|' from 'page_obj.number|'.
Please help 🙏 🙏🙏🙏🙏🙏🙏🙏🙏

eugenetuhaisr
Автор

Many times I refused to watch youtube tutorials because I think that they are useless.Today I watched your 11 videos continuously thank you I wish you will get a fair shot :)

berkayyalcn
Автор

I may have downloaded your c. 80 videos using youtube-dl but I'm still coming back to hit that like button, you're a saint to aspiring devs everywhere, keep it up!

robmenon
Автор

Thanks for this Corey :)

I tried to add a functionality to display all my post by visiting my profile page and clicking the profile picture. :) And successfully done it. Hehe So proud of myself. Thanks Corey sir. :) Just sharing. Hehe

ivancarcallas
Автор

This whole tutorial series is beast mode. It would be amazing if you could make a tutorial series on building a simple ML app. Something like the user gives some text input and the output is some sentiment score or something using scikit-learn, tensor flow, or pytorch. I would love to see how you would design the layout of that kind of website/web-app using Django.

michaelcortes
Автор

You making videos with an actual sense of spreading knowledge instead of buying likes and shares. One of the best Django tutorials available on internet. Thankyou from Germany.

paramveermarwah
Автор

Big thumb up for all this tutorial ! It's really simple and clear to understand !

For those like me who are using django in version > 3, for the order_by in the get_queryset method, we need to do it before the filter call like :
<< return >>

nicolasroosz
Автор

At 22:00 in the end of paginations.
I did some changes on the pagination buttons I hope you like it:
{% if is_paginated %}

{% if page_obj.has_previous %}
<a class="btn btn-outline-info mb-4" href="?page=1">First</a>
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.previous_page_number }}">Previous</a>
{% else %}
<a class="btn btn-outline-secondary mb-4" href="#">First</a>
<a class="btn btn-outline-secondary mb-4" href="#">Previous</a>
{% endif %}

{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<a class="btn btn-info mb-4" href="?page={{ num }}">{{ num }}</a>
{% elif not page_obj.has_previous %}
{% if num <= page_obj.number|add:'2' %}
<a class="btn btn-outline-info mb-4" href="?page={{ num }}">{{ num }}</a>
{% endif %}
{% elif not page_obj.has_next %}
{% if num >= page_obj.number|add:'-2' %}
<a class="btn btn-outline-info mb-4" href="?page={{ num }}">{{ num }}</a>
{% endif %}
{% elif num >= page_obj.number|add:'-1' and num <= page_obj.number|add:'1' %}
<a class="btn btn-outline-info mb-4" href="?page={{ num }}">{{ num }}</a>
{% endif %}
{% endfor %}

{% if page_obj.has_next %}
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.next_page_number }}">Next</a>
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.paginator.num_pages }}">Last</a>
{% else %}
<a class="btn btn-outline-secondary mb-4" href="#">Next</a>
<a class="btn btn-outline-secondary mb-4" href="#">Last</a>
{% endif %}

{% endif %}

marcelo
Автор

I spent 2 hours figuring out it was supposed to be get_queryset() not get_query_set() and just when I planned on sharing this valuable info in comments, as I moved ahead of video to get the screen he explained this. Oh god.. don, t know if jumping ahead is good or bad anymore.:( But greatful for the content Corey. Almost everything I know in Django is because of you. Thank you.

shashikalaraju
Автор

1:40 getting data from json in shell
4:45 Paginator
8:45 using Paginator with class based view (CBV)
11:30 adding pagination UI in templates
23:00 filtered data Paginator with class based view (CBV) get_queryset
25:05 get_object_or_404

삼겹살_옆_된장국
welcome to shbcf.ru