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

Комментарии • 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 😎🙌

  • @sagargautam6787
    @sagargautam6787 4 месяца назад

    Thanks bro

  • @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.

  • @djangodeveloper2973
    @djangodeveloper2973 Год назад

    Amazing. Thanks

  • @oparesimon
    @oparesimon Год назад +1

    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.

    • @Pyplane
      @Pyplane  Год назад

      Thanks! 🙌 Glad you liked the video ✨

  • @tshiamomotshabi9862
    @tshiamomotshabi9862 Год назад

    Love these types of content, very insightful.

    • @Pyplane
      @Pyplane  Год назад

      Thank you! 🙌✨

  • @damianrutkowski1161
    @damianrutkowski1161 Год назад

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

    • @Pyplane
      @Pyplane  Год назад +1

      Dzięki Damian! Pozdr 🙌✨

  • @yogeshyts
    @yogeshyts Год назад

    very informative video for absolute beginners

  • @developer-pf2fl
    @developer-pf2fl Год назад

    What an amazing tutorial . Thankyou

    • @Pyplane
      @Pyplane  Год назад +1

      Thanks for watching! 🙌

  • @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 🙌✨

  • @HackSoft
    @HackSoft Год назад

    Well explained ✨

    • @Pyplane
      @Pyplane  Год назад +1

      Thank you! Glad you liked it ✨🙌

  • @ilyosbekkarshiboyev7134
    @ilyosbekkarshiboyev7134 Год назад

    Good luck thank you