How to use annotate and aggregate on Django querysets

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 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

ความคิดเห็น • 26

  • @piyushgupta4714
    @piyushgupta4714 3 หลายเดือนก่อน

    very good tutorial

  • @SisiraSomaratne
    @SisiraSomaratne ปีที่แล้ว

    So Simple!, so Clear!
    Thank you very much!
    Two or three days reading and studying of Django documentation is finished by 15 min.

  • @mr.h3758
    @mr.h3758 3 หลายเดือนก่อน

    Clear and simple, perfect !

  • @oparesimon
    @oparesimon ปีที่แล้ว +1

    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.

    • @Pyplane
      @Pyplane  ปีที่แล้ว

      Maybe I’ll include this topic in a Django Project tutorial which I’ll publish in the near future 😎🙌

  • @anunnaki_7
    @anunnaki_7 ปีที่แล้ว +2

    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"

    • @Pyplane
      @Pyplane  ปีที่แล้ว +2

      This is why you shouldn’t do copy & paste 🫣 you are 100% correct 🙌

    • @061N
      @061N ปีที่แล้ว

      You are a great student.

  • @sagargautam6787
    @sagargautam6787 3 หลายเดือนก่อน

    Thanks bro

  • @oparesimon
    @oparesimon ปีที่แล้ว +1

    Very good tutorial. I can confidently tell you that, for some few months now, I've been combing the whole TH-cam for such a video & I am not getting it. God bless you so much.

    • @Pyplane
      @Pyplane  ปีที่แล้ว

      Thanks! 🙌 Glad you liked the video ✨

  • @damianrutkowski1161
    @damianrutkowski1161 ปีที่แล้ว

    Super prosty i uzyteczny tutorial, jak zwykle. Łapka w górę zasłużona

    • @Pyplane
      @Pyplane  ปีที่แล้ว +1

      Dzięki Damian! Pozdr 🙌✨

  • @tshiamomotshabi9862
    @tshiamomotshabi9862 ปีที่แล้ว

    Love these types of content, very insightful.

    • @Pyplane
      @Pyplane  ปีที่แล้ว

      Thank you! 🙌✨

  • @djangodeveloper2973
    @djangodeveloper2973 ปีที่แล้ว

    Amazing. Thanks

  • @Omar00113
    @Omar00113 ปีที่แล้ว

    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

    • @Pyplane
      @Pyplane  ปีที่แล้ว +1

      Glad you liked it and good luck on the project 🙌✨

  • @developer-pf2fl
    @developer-pf2fl ปีที่แล้ว

    What an amazing tutorial . Thankyou

    • @Pyplane
      @Pyplane  ปีที่แล้ว +1

      Thanks for watching! 🙌

  • @yogeshyts
    @yogeshyts ปีที่แล้ว

    very informative video for absolute beginners

    • @Pyplane
      @Pyplane  ปีที่แล้ว

      Thank you! 🙌

  • @HackSoft
    @HackSoft ปีที่แล้ว

    Well explained ✨

    • @Pyplane
      @Pyplane  ปีที่แล้ว +1

      Thank you! Glad you liked it ✨🙌

  • @ilyosbekkarshiboyev7134
    @ilyosbekkarshiboyev7134 ปีที่แล้ว

    Good luck thank you

    • @Pyplane
      @Pyplane  ปีที่แล้ว

      🙌🙌🙌