How to use annotate and aggregate on Django querysets
HTML-код
- Опубликовано: 17 сен 2024
- Tutorial on how to use annotate and aggregate on Django querysets
In this video we'll analyze use cases for annotate() and aggregate() functions used on django querysets in order to retrieve a summary of statistics interesting for the user
🔥 Join the Facebook group:
/ djangoninjas 🚀
🔥 Follow pyplane on:
➜ instagram: / pyplane_code
➜ pinterest: / pyplane
➜ facebook: / pyplane
🔥 More on python and django:
➜ blog.pyplane.com
#pythondjango #djangotutorial #djangoproject
django 4, python web framework, django aggregation, django tutorial, django making queries, django annotate, django orm, django querysets, django querydict, django programming, django tutorial 2023, django development, django database, django framework tutorial, django framework python, django db model, python django web development
very good tutorial
So Simple!, so Clear!
Thank you very much!
Two or three days reading and studying of Django documentation is finished by 15 min.
Clear and simple, perfect !
I wish you can make a part 2 or even more tutorials on this.
What if you want to use the aggregate and annotate with some conditions?
Eg. 1 - Where you want to sum the 3 most minimum of each customer. assuming each customer has made at least 3 purchases.
Eg. 2. Where you sum the purchase of each customer, excluding the purchase of a particular product or excluding the product with a specific amount.
Maybe I’ll include this topic in a Django Project tutorial which I’ll publish in the near future 😎🙌
Thanks bro
Hi, this is a Greate tutorial, but I have question, in minute 10:07 you used this query "Customer.objects.filter(id=1).aggregate(Count('purcheses__amount))" to get the count of purchases for each customer.
why did you need to specify "purcheses__amount" in the Count function to get the purchases count, why not specified just the "purchases" only, it will count the purchases for each user.
in short, we need to count the purchases for each customer, not the purchases__amount, so is it will be more logical to put the "purchases" there not "purcheses__amount"
This is why you shouldn’t do copy & paste 🫣 you are 100% correct 🙌
You are a great student.
Amazing. Thanks
Very good tutorial. I can confidently tell you that, for some few months now, I've been combing the whole RUclips for such a video & I am not getting it. God bless you so much.
Thanks! 🙌 Glad you liked the video ✨
Love these types of content, very insightful.
Thank you! 🙌✨
Super prosty i uzyteczny tutorial, jak zwykle. Łapka w górę zasłużona
Dzięki Damian! Pozdr 🙌✨
very informative video for absolute beginners
Thank you! 🙌
What an amazing tutorial . Thankyou
Thanks for watching! 🙌
I am currently building a dashboard for a side project with a django backend. I was planning on using raw sql queries and was procrastinating because of how ugly that would be. This tutorial is very timely. Thanks
Glad you liked it and good luck on the project 🙌✨
Well explained ✨
Thank you! Glad you liked it ✨🙌
Good luck thank you
🙌🙌🙌