Database Model Queries | Django (3.0) Crash Course Tutorials (pt 7)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ค. 2024
  • Checkout my new Django Course!
    dennisivy.teachable.com/p/dja...
    Django database queryesets
    Follow me on Twitter: / dennisivy11
    Linkedin: / dennis-ivanov
    Source code + Live Demo: dennis-sourcecode.herokuapp.c...

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

  • @jakeroosenbloom
    @jakeroosenbloom 4 ปีที่แล้ว +23

    Holy shit dude this might be the best tutorial series on any subject ever I have seen on TH-cam (not just programming or web development)

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +4

      Haha thanks Jake :)

  • @kken8766
    @kken8766 4 ปีที่แล้ว +75

    I've done 2 Udemy Django classes and 2 youtube tutorial series and this is by far the best of them. The way you take your time to make the slides and layout the queries function and example shows that you care about us. thanks.

    • @rokhribar5512
      @rokhribar5512 4 ปีที่แล้ว

      Could you recommend a follow up course/site for us beginners after this crash course? Ty

  • @joaojesus8861
    @joaojesus8861 3 ปีที่แล้ว +5

    Dennis I cannot stress how helpful and clear your work is. Other channels don’t explain properly or complicate it too much when the point is to introduce simple topics. Im sure you are going a long way ;) Wish you all the best mate!

  • @reetamchatterjee2179
    @reetamchatterjee2179 4 ปีที่แล้ว +11

    Best django series on youtube. Learning a lot!! Thanks Dennis!!

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

    Dennis, I can't thank you enough! This "query_set" part was killing me! Even the Django documentation does not cover this topic properly!

  • @kewartoscar8913
    @kewartoscar8913 4 ปีที่แล้ว

    Thanks for your precious service to humanity. I nearly quit Django and I chanced on your videos on youtube. You have inspired new hope in me, and have increased my passion for Django. I am amazed by your selfless nature, and your willingness to share knowledge and help others.

  • @barscankurt4854
    @barscankurt4854 3 ปีที่แล้ว

    So far so good. This tutorial is really detailed, organized and understandable. If you make all of your tutorials like this eventually people gonna discover this channel. You can be the next "code with mosh".

  • @veyselaksin
    @veyselaksin 2 ปีที่แล้ว

    I think this is best ever Django course in TH-cam. You explain things simply! Thank for this course.

  • @philiponyeachonam6724
    @philiponyeachonam6724 4 ปีที่แล้ว

    this is one of the best tutorials out here on Django, I really understood the database queries more than any pdf or youtube videos. Thanks a lot Sir

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

    Thank you Dennis. This Django series is by far the best series on the internet. Learning a lot from it. Learnt Python from CodeWithHarry, and learning Django from you. I can't thank you enough for this awesome tutorial. Love from Nepal Brother.

  • @byabaci12
    @byabaci12 4 ปีที่แล้ว

    One of the smoothest tutorial set I've ever seen.. Thank you!

  • @shivamm3401
    @shivamm3401 3 ปีที่แล้ว

    This is a great series, so easy to follow and descriptive. Keeps me motivated!

  • @luizzeduardo341
    @luizzeduardo341 4 ปีที่แล้ว +18

    Very good your explanations, congratulations for the content and the prepared material.
    Excellent quality!

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +4

      Thank you Luiz:)

  • @sanjayshirodkar
    @sanjayshirodkar 3 ปีที่แล้ว

    This course is the best ... I am learning so much doing this course. Thanks a ton Dennis.

  • @mohammedqadir3851
    @mohammedqadir3851 4 ปีที่แล้ว +6

    Thank you sir clear all concept of Django.

  • @kevincampbell256
    @kevincampbell256 3 ปีที่แล้ว

    Thanks Dennis, I really appreciate this series you created.

  • @udbhavn8368
    @udbhavn8368 3 ปีที่แล้ว

    Ohh man i finally found a good django course...Really love the effort you put into theses videos man...Amazing

  • @talha_anwar
    @talha_anwar 3 ปีที่แล้ว

    This tutorials is far better than many paid. to the point, precise theory concept before implementation

  • @yashrajpahwa
    @yashrajpahwa 3 ปีที่แล้ว

    Hey Dennis, this goes to you... You have taught in the best way possible... KUDOS!!! 👌🙏

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

    From 11.01-11.11 instead of using multiple newline you can use ctrl+l that can throw all your terminal codes to above unseen area. Thank you.

  • @llewellynhattingh3496
    @llewellynhattingh3496 3 ปีที่แล้ว

    you are incredible! You deserve a nice cold beer! Thanks so much, helped me a lot

  • @earljohncalizar1154
    @earljohncalizar1154 3 ปีที่แล้ว

    I'm not gonna lie. This channel is awesome. Got udemy courses and some youtube playlist. But this MAN really THE BEST OF IT. Thanks sir. SAVE ME ON MY SCHOOL PROJECT

  • @xochdt
    @xochdt 4 ปีที่แล้ว

    I love how you teach. If it wasn't for you I'd probably wouldn't have followed my programing learning. Sincerly, thanks

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      Wow that inspires me! Thank you for taking the time to comment :) Best of luck

  • @grzegorz-gregmika8339
    @grzegorz-gregmika8339 4 ปีที่แล้ว +1

    Hope you never stop, great job! Think about document DB or Firebase

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

      Im blown away by how much support I get over this series, thank you! I’m taking this comment into consideration for my next videos :)

  • @nakhan69
    @nakhan69 2 ปีที่แล้ว

    K Ken I totally agree with you, I am a beginner and I find it very useful. Thank you Dennis

  • @CraftscollectionCoUkshop
    @CraftscollectionCoUkshop 4 ปีที่แล้ว

    Thanks so much Denis. Can't believe that your tutorials are free. Better than Python Django Bootcamp that I bought on Udemy which is never updated. Usually I don't subscribe to TH-cam but has to do it on yours because of how good it is. Keep it up.

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      Thank you :)

  • @sangeethsubramoniam3094
    @sangeethsubramoniam3094 3 ปีที่แล้ว +6

    Cheat sheet .... Welcome !
    #***(1)Returns all customers from customer table
    customers = Customer.objects.all()
    #(2)Returns first customer in table
    firstCustomer = Customer.objects.first()
    #(3)Returns last customer in table
    lastCustomer = Customer.objects.last()
    #(4)Returns single customer by name
    customerByName = Customer.objects.get(name='Peter Piper')
    #***(5)Returns single customer by name
    customerById = Customer.objects.get(id=4)
    #***(6)Returns all orders related to customer (firstCustomer variable set above)
    firstCustomer.order_set.all()
    #(7)***Returns orders customer name: (Query parent model values)
    order = Order.objects.first()
    parentName = order.customer.name
    #(8)***Returns products from products table with value of "Out Door" in category attribute
    products = Product.objects.filter(category="Out Door")
    #(9)***Order/Sort Objects by id
    leastToGreatest = Product.objects.all().order_by('id')
    greatestToLeast = Product.objects.all().order_by('-id')
    #(10) Returns all products with tag of "Sports": (Query Many to Many Fields)
    productsFiltered = Product.objects.filter(tags__name="Sports")
    '''
    (11)Bonus
    Q: If the customer has more than 1 ball, how would you reflect it in the database?
    A: Because there are many different products and this value changes constantly you would most
    likly not want to store the value in the database but rather just make this a function we can run
    each time we load the customers profile
    '''
    #Returns the total count for number of time a "Ball" was ordered by the first customer
    ballOrders = firstCustomer.order_set.filter(product__name="Ball").count()
    #Returns total count for each product orderd
    allOrders = {}
    for order in firstCustomer.order_set.all():
    if order.product.name in allOrders:
    allOrders[order.product.name] += 1
    else:
    allOrders[order.product.name] = 1
    #Returns: allOrders: {'Ball': 2, 'BBQ Grill': 1}
    #RELATED SET EXAMPLE
    class ParentModel(models.Model):
    name = models.CharField(max_length=200, null=True)
    class ChildModel(models.Model):
    parent = models.ForeignKey(Customer)
    name = models.CharField(max_length=200, null=True)
    parent = ParentModel.objects.first()
    #Returns all child models related to parent
    parent.childmodel_set.all()

  • @ansariarbaz3374
    @ansariarbaz3374 4 ปีที่แล้ว

    You know there are turns in life whereafter everything becomes smooth. Your vedios are like dat turn awesome dude..

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

    Hi Dennis, thanks a lot for your effort and you're really a good instructor, good luck

  • @muhammadsameer9647
    @muhammadsameer9647 3 ปีที่แล้ว

    Man the way you teach is awesome.

  • @medoune89
    @medoune89 4 ปีที่แล้ว

    WAOUH !!!!
    VERY COMPLETE PLAYLIST for Beginner

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

    Thank you for these videos. I love this content so much!

  • @youcef659
    @youcef659 4 ปีที่แล้ว

    I wanna thank you for your efforts and for the amazing videos you make with a very good explanation
    good luck

  • @khaki714
    @khaki714 3 ปีที่แล้ว

    Well done. Nice series.

  • @mohcench1903
    @mohcench1903 4 ปีที่แล้ว

    thank you so much for your work , the way u explain is amazing keep it up :)

  • @shefat9892
    @shefat9892 4 ปีที่แล้ว

    659 likes over against 1 dislike describe how gracefully you explained everything...

  • @dawid_dahl
    @dawid_dahl 3 ปีที่แล้ว

    Thank you so much!
    (Great little cheat sheet, too. Saved!)

  • @akramnarejo6221
    @akramnarejo6221 3 ปีที่แล้ว

    guess what? today you made me realize that it is the teacher who makes an student interested in learning. believe me constantly I am watching and learning ur tuts and did not get bore yet. truly love you man.

    • @akramnarejo6221
      @akramnarejo6221 3 ปีที่แล้ว

      before you I have watched others too but fortunately ended up to urs tuts.

  • @kishanpanchal5009
    @kishanpanchal5009 4 ปีที่แล้ว

    bro this video is really cool and intrustinng thanks and i really appreciated for this type of presentation on Django,

  • @mursalrabb6093
    @mursalrabb6093 3 ปีที่แล้ว

    Definitely the best series on django @YT

  • @Nemosaur
    @Nemosaur 3 ปีที่แล้ว

    Super helpful!
    Thanks so much!

  • @leomacenauer3433
    @leomacenauer3433 3 ปีที่แล้ว

    Thanks a lot ! Amazing work !

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

    You are doing so gooood! I hope you will be famous one day..just keep on working like that ❤👌👍

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +3

      Haha I appreciate that :)

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

    The way you structured this tutorial on django alongside the source code is amazing... Please do a tutorial on how you hosted it onto heroku... Thanks

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

      Putting this app on heroku soon, hopfully this week :)

  • @romit5867
    @romit5867 4 ปีที่แล้ว

    your tutorial is awesome and really appreciate the way you explain... thank you.... right now i am going to subscribe and hit that bell icon

  • @hyperxelon2838
    @hyperxelon2838 2 ปีที่แล้ว

    Your videos are awesome easy to understand

  • @avikumar9046
    @avikumar9046 3 ปีที่แล้ว

    Sir your Videos are just Awesome thanks a lot..Love from India.

  • @shaxzod6485
    @shaxzod6485 3 ปีที่แล้ว

    amazing course)

  • @ahmedtahir6034
    @ahmedtahir6034 4 ปีที่แล้ว

    You're Awesome Bro!!!

  • @abdulwadood9484
    @abdulwadood9484 4 ปีที่แล้ว

    Bro you doing well. Keep doing for us

  • @user-ej7qx8gl7u
    @user-ej7qx8gl7u 11 หลายเดือนก่อน

    thanks Mr dennis

  • @doniyorabduvokhidov1862
    @doniyorabduvokhidov1862 4 ปีที่แล้ว

    Awesome Thanks a lot!!!!

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

    Hi Dennis. Your video is awesome. It is really nice and understandable. Keep going. And I think you are the best Django teacher because on Russian youtube or American I don't see normal videos. You the best #DennisIvyTheBest #2020

  • @DanielLeachTen
    @DanielLeachTen 2 ปีที่แล้ว

    Thank you so much!

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

    Its a very nice and useful video i like it must

  • @uttarpustika
    @uttarpustika 3 ปีที่แล้ว

    best explained thankyou

  • @amanbhullar1908
    @amanbhullar1908 3 ปีที่แล้ว

    Hi Dennis Ivy .I am following your tutorials i really like the way you are explaining the things . can you please suggest other projects so i can work as a beginner to explore more about django. Thanks

  • @apolovzla_ccs
    @apolovzla_ccs 4 ปีที่แล้ว

    Hi guys, hi Dennis. Thank you very much for your effort in creating this course.
    I have a question related to the ball case in the last part of the video, wouldn't it be easier to add a quantity field to the order table for each chosen item?

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

    Buenísimo gracias

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

    Hey Denise, thank you for this tutorial, really helpful. Could you show how to create a customized id field in a model?

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

      I'd have to do some research on that myself. Haven't really customized any fields outside of adding some widgets. I'm make a video on this once i do some more research :)

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

      @@DennisIvy Sure. Meanwhile ,I've worked on a code myself, where I call a function from a field to add data and set the field to uneditable

  • @Magistrado1914
    @Magistrado1914 4 ปีที่แล้ว

    Excellent course
    12/07/2020

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

    Your series are just awesome, man! I do my best to support you with likes, subscruption, recommendations etc.

  • @d11vory
    @d11vory 4 ปีที่แล้ว

    damn man, you are the best!

  • @nishantpacharne1569
    @nishantpacharne1569 4 ปีที่แล้ว

    Please Dennis make a series of Html Css and Bootstrap , please !!!! , and by the way you create awesome stuff !!

  • @sagargahatraj5196
    @sagargahatraj5196 4 ปีที่แล้ว

    hey dennis bro please show how to pull the data from many to many datas from table

  • @successsoi
    @successsoi 4 ปีที่แล้ว +6

    Dennis thanks a lot for this tutorial. My question is the queriesDemos.py file, do we have to create one for whatever app we are building before we can actually query our database in our templates?

    • @Saketh-Chandra
      @Saketh-Chandra 2 ปีที่แล้ว

      No need, Dennis is just showing examples.

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

    Hi Dennis thank you for your youtube tutorials I know it has been a long time since you posted this one, but I got to ask the source code is not working is there any way we can get them again
    thank you keep up the great work

  • @rayganmudberry375
    @rayganmudberry375 4 ปีที่แล้ว

    Great

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

    Hello Sir can you help me in this...?
    I have two models A and B which having many to many relation and form third model E with extra attributes .
    so i want to perform following sql query using django :
    select * from A , B , E where A.id = E.id and B.id = E.id and A.id = '107';
    how i can do..?
    A.objects().filter(e__aid=107)
    geves me only content from A model.
    Plzz Help..?

  • @tanishtyagi1301
    @tanishtyagi1301 3 ปีที่แล้ว

    is there a way to query by row number in django. e.g. return row data of row #1?

  • @ioan-alexandruilasi6987
    @ioan-alexandruilasi6987 4 ปีที่แล้ว +99

    Who else decided to learn about web development while in lockdown? :)

  • @alieeldeenahmed2278
    @alieeldeenahmed2278 3 ปีที่แล้ว

    When i wrote customers = Customer.object.all() and then print it
    that what appeared ''
    no names appeared so what is the problem??

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

    A great explanation and a superb set of tutorials. One question. Could not an order have many products as opposed to just a single one in your example?

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      In this case no. Its a purchased item and not a set of orders. So lets say you place an order on amazon, you can have a shopping cart full of orders that relate to many products but each individual order must tie only to one product. You could however have quantity attribute. Is that what you were thinking?

    • @binghamdt
      @binghamdt 4 ปีที่แล้ว

      @@DennisIvy Yes that was my idea. Again thanks for all the hard work on the tutorials.

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      Your welcome David :) it makes me very happy when I get feedback on everyone’s progress. Glad I can help :)

  • @othmanechalal2401
    @othmanechalal2401 11 หลายเดือนก่อน +2

    Thank you for everything dude! But we can't have access to the source code anymore plz fix it

  • @UmangDhandhania
    @UmangDhandhania 4 ปีที่แล้ว

    How can I have more project based courses like these on Django? @Dennis Ivy. I'm up for paid courses.

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

    I download your source code but It still has some error in queryDemos.py

  • @amanojha924
    @amanojha924 2 ปีที่แล้ว

    Can you make one for uploading excel file and how to CRUD it in db

  • @naimahmed8495
    @naimahmed8495 4 ปีที่แล้ว

    hey i can't save changes in the admin panel.my django version is 2.1.Can anyone help me?

  • @aswn18
    @aswn18 2 ปีที่แล้ว

    13:15 will product.name work instead of product__name, both mean the same right?

  • @scattyrot
    @scattyrot 3 ปีที่แล้ว

    can we use default dict for allOrders?

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

    where is the link :P I had to search the documentation online

  • @jaitungodhani2334
    @jaitungodhani2334 2 ปีที่แล้ว

    In this, order_set method not work plz you have any solutions tell me

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

    'Customer' object has no attribute 'order_set' this error arrives when I test.Can someone please help me with that

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

    hi
    the source code link isn't working

  • @abhi-rw5lt
    @abhi-rw5lt ปีที่แล้ว +1

    sad, link is not working, i cant access the source code :(

  • @JOAOFELIPEQUENTINO
    @JOAOFELIPEQUENTINO 2 หลายเดือนก่อน

    why the links of the description of other materials never are in the description
    😭

  • @md.shariarkabir7350
    @md.shariarkabir7350 3 ปีที่แล้ว +1

    I didn't find the query cheatsheet in github.

  • @AbdallahSallam88
    @AbdallahSallam88 3 ปีที่แล้ว

    Search this for the documentation QuerySet API reference

  • @jaitungodhani2334
    @jaitungodhani2334 2 ปีที่แล้ว

    'Customer' object has no attribute 'order_set' this error arrives when i test

  • @qwertysriram
    @qwertysriram 4 ปีที่แล้ว

    Doing a great job bro..................i have a doubt, which is the best database for django other than the default sqlite?

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

      Definitely Postgres. Although you can use any database, Django was built with postgres in mind so integration is seamless. I’ll be making a video on how to do this soon :) and thank you for the support!

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

    i'm getting an error working on the shell after print(customers)
    return Database.Cursor.execute(self, query, params)
    django.db.utils.OperationalError: no such table:

    • @beakmann
      @beakmann 3 ปีที่แล้ว

      Run
      $ python manage.py migrate

  • @avitinformatics8221
    @avitinformatics8221 4 ปีที่แล้ว

    I wonder how this SqlAlchemy handles thousands of data in real time projects, is this only option ?

  • @RavinderSingh-un7ky
    @RavinderSingh-un7ky 4 ปีที่แล้ว

    Can you make a video on middlewares, context managers, Restful web API

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +3

      Yep! Middleware and a rest API course are actually on my list of videos to do :)

  • @HydoSkills
    @HydoSkills 2 ปีที่แล้ว

    Me a 35 yo male: haha peter piper initial are P, P.. Good tutorial series my man!

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

    Hey Dennis just wanted to let you know that your source code link inst working...

  • @tokhenz
    @tokhenz 9 หลายเดือนก่อน

    Hi, are you going to address the complaints regarding the missing source code?

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

    the code source is missing :(

  • @EltigreTafur
    @EltigreTafur 4 ปีที่แล้ว

    how return the response to template

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

    Your Source code + Live Demo Link Can't Work Please Check this problem

  • @venkatrao235
    @venkatrao235 2 ปีที่แล้ว

    nice explanation sir tq ,query for students having equal marks how can give ranks by date of birth