No video

Django select_related Examples |Django select_related and prefetch_related |Django n+1 Query Problem

  Рет қаралды 31,610

Code Band

Code Band

Күн бұрын

Пікірлер: 104
@CodeBand
@CodeBand 4 жыл бұрын
Django prefetch_related | Django select_related vs prefetch_related : kzbin.info/www/bejne/a164f2ePhal3h8U
@evanwhite4190
@evanwhite4190 3 жыл бұрын
This makes so much more sense than the documentation. Thank you!
@CodeBand
@CodeBand 3 жыл бұрын
Glad to hear that...you can also checkout prefetch_related here : kzbin.info/www/bejne/a164f2ePhal3h8U
@sayadahmedshaurov8639
@sayadahmedshaurov8639 3 жыл бұрын
I was looking for this kind of explanation with example. What everyone does is just talks about theory. Thanks for making more sense by giving an example.
@CodeBand
@CodeBand 3 жыл бұрын
Glad to hear that brother...😊
@rahul_singh_rajput3292
@rahul_singh_rajput3292 Жыл бұрын
hhmm. delicious example 😌🔥..
@CodeBand
@CodeBand Жыл бұрын
Thank you 🙌
@oruchkin
@oruchkin 3 жыл бұрын
Very good thanks
@CodeBand
@CodeBand 3 жыл бұрын
Most welcome
@PrriyanshuSharmaa
@PrriyanshuSharmaa 3 жыл бұрын
Thank You so much bro.
@CodeBand
@CodeBand 3 жыл бұрын
Glad to hear that😊
@vinodinti
@vinodinti 3 жыл бұрын
very good bro.
@CodeBand
@CodeBand 3 жыл бұрын
Thanks a lot👍🏻
@likeitthings8418
@likeitthings8418 2 жыл бұрын
thank you so much it helped me alot
@CodeBand
@CodeBand 2 жыл бұрын
Glad it helped!
@amirhosseinebneroomi7280
@amirhosseinebneroomi7280 2 жыл бұрын
amazing..
@CodeBand
@CodeBand 2 жыл бұрын
Thanks a lot
@mohammadfaisal2039
@mohammadfaisal2039 Жыл бұрын
Thank you, for good explanations
@CodeBand
@CodeBand Жыл бұрын
Glad to hear that :)
@hachhh
@hachhh 11 ай бұрын
Thank you!! Very clear explanation.
@zoromahm
@zoromahm 4 жыл бұрын
So useful. Thanks for the video.
@CodeBand
@CodeBand 4 жыл бұрын
Glad it was helpful!
@mmafhbmmafhb3555
@mmafhbmmafhb3555 3 жыл бұрын
thank you , you save me :)
@CodeBand
@CodeBand 3 жыл бұрын
You're welcome!
@user-ib4pu5zr7l
@user-ib4pu5zr7l 3 жыл бұрын
Thank you ! The explanation is awesome)
@CodeBand
@CodeBand 3 жыл бұрын
Glad to hear that...😊
@behruzisaev2102
@behruzisaev2102 2 жыл бұрын
Great explanation, bro. Thanks a lot!
@CodeBand
@CodeBand 2 жыл бұрын
Glad it was helpful!
@omidasadi2264
@omidasadi2264 2 жыл бұрын
it was great, thanks for sharing
@CodeBand
@CodeBand 2 жыл бұрын
Glad you enjoyed it
@ricardomoha14
@ricardomoha14 2 жыл бұрын
Your video is really great, up to the point and easy to understand, just onething.. Try being a bit faster.. I think the video could have been done in 5 minutes instead of 12.
@CodeBand
@CodeBand 2 жыл бұрын
Thanks a lot and I have noted down the suggestion and will try to improve in future...
@santiagobustamante970
@santiagobustamante970 4 жыл бұрын
Great video and thanks for the tool, so useful! you saved hours of my life Thanks again man
@CodeBand
@CodeBand 4 жыл бұрын
Glad it helped! Keep supporting 😊
@MuhammadMahirQ8
@MuhammadMahirQ8 4 жыл бұрын
awesome broo.. highly appreciated
@CodeBand
@CodeBand 4 жыл бұрын
Glad to hear that brother...Please share in your circle too...Thanks a lot... :)
@nikeshthakor406
@nikeshthakor406 2 жыл бұрын
Thanks
@CodeBand
@CodeBand 2 жыл бұрын
Welcome.. :)
@digambar6191
@digambar6191 Жыл бұрын
Thanx sir
@romanbush5164
@romanbush5164 Жыл бұрын
ThankS!
@SAIFHASANAT-cm8xh
@SAIFHASANAT-cm8xh 4 ай бұрын
thank you
@harshamachine_learning7831
@harshamachine_learning7831 4 жыл бұрын
Thanks for select related Please include prefetch related asap
@CodeBand
@CodeBand 4 жыл бұрын
Definitely, I will upload it very soon. Thanks😊
@CodeBand
@CodeBand 4 жыл бұрын
I have done the video of prefetch_related.😊 Please do let me know your suggestions in the comments. Thank you☺️ kzbin.info/www/bejne/a164f2ePhal3h8U
@harshamachine_learning7831
@harshamachine_learning7831 4 жыл бұрын
@@CodeBand video looks good, it covers key basic areas of that method
@CodeBand
@CodeBand 4 жыл бұрын
Thanks❤️
@azizbekgulomov2881
@azizbekgulomov2881 3 жыл бұрын
Yeah good job! Keep it up!
@CodeBand
@CodeBand 3 жыл бұрын
Thanks a lot👍🏻
@josemanuel9137
@josemanuel9137 4 жыл бұрын
good explanation bro!
@CodeBand
@CodeBand 4 жыл бұрын
Glad you liked it! Thanks for the support and keep supporting :)
@rangabharath4253
@rangabharath4253 4 жыл бұрын
awesome
@CodeBand
@CodeBand 4 жыл бұрын
Thanks a lot 😊
@imranshaikh-bt5ln
@imranshaikh-bt5ln 7 ай бұрын
Hi which extension have you added on your browser to show requests and response time?
@joshuahadap2373
@joshuahadap2373 4 жыл бұрын
All I can say is I love you!
@CodeBand
@CodeBand 4 жыл бұрын
Thanks a lot...Keep supporting... ☺️
@bricegnanago409
@bricegnanago409 3 жыл бұрын
So good ! Now how make a left join query with select_related please
@CodeBand
@CodeBand 3 жыл бұрын
Glad to hear that...have a quick research on left join and you'll find an answer...keep going👍🏻
@pritamghosh270
@pritamghosh270 4 жыл бұрын
Great explained. Thanks 😊 . If I want objects of Employee table from Department then what to do? For an expample, I want some employees under a specific department. But I want it from the Department model not from Employee. That time what to do?
@CodeBand
@CodeBand 4 жыл бұрын
Glad to hear that😊. In the case you mentioned, there is no chance of raising an N+1 query problem, because, department id will be there with you, and you just need to fetch all the employees with that specific dept. id, so at most 2 queries will be required. Hope this helps and I recommend you to watch the prefetch_related too... kzbin.info/www/bejne/a164f2ePhal3h8U
@misfarsiddeek3105
@misfarsiddeek3105 4 жыл бұрын
Brother, can you do a complete CRUD video with validation also? For the data input please use raw html forms. Without using Model Form or django form.
@CodeBand
@CodeBand 4 жыл бұрын
Will try to do that in the future brother...Thanks for the suggestion... :)
@misfarsiddeek3105
@misfarsiddeek3105 4 жыл бұрын
@@CodeBand sure. I am waiting for that video.
@CodeBand
@CodeBand 4 жыл бұрын
:)
@danarardiwinanto
@danarardiwinanto 2 жыл бұрын
Sir... I want to output count employee per department. let's say I have 8 departments, and I want to outputing all department with and without employee. How can I do this? Thankyou
@CodeBand
@CodeBand 2 жыл бұрын
Sorry for the late reply... Did you figured it out?
@danarardiwinanto
@danarardiwinanto 2 жыл бұрын
@@CodeBand Yes, I have figured it out. I need to annotate (right join) my employee_id on department table. Should be like this: Department.objects.values('id_department').annotate(Counter=Count('employee')).values('id_department', 'Counter')
@yollaifliandry495
@yollaifliandry495 2 жыл бұрын
Thank you. By the way, is it possible to use select_related in class-based view ?
@CodeBand
@CodeBand 2 жыл бұрын
Hey, for sure. It doesn't matter whether you use CBV/FBV.
@FitriWibowo
@FitriWibowo 4 жыл бұрын
Very nice video, can we do the same thing with the Q keyword in Django
@CodeBand
@CodeBand 4 жыл бұрын
Thanks a lot brother...There are a couple of ways of doing it...and this one stands out in terms of performance... :)
@mfsdrawings8600
@mfsdrawings8600 4 жыл бұрын
👍🏻👍🏻👍🏻👍🏻❤️
@CodeBand
@CodeBand 4 жыл бұрын
Thanks a lot brother... :)
@jmdesros
@jmdesros 2 жыл бұрын
What if an employee doesn't have a department?
@CodeBand
@CodeBand 2 жыл бұрын
Sorry for the late reply... That depends on the foreign key configurations.
@RedElectrik
@RedElectrik 4 жыл бұрын
You should remove "prefetch_related" from the title. You don't talk about it
@RedElectrik
@RedElectrik 4 жыл бұрын
Your also dont seem to have made a video about it anywhere
@CodeBand
@CodeBand 4 жыл бұрын
Actually, I planned to do both in a single video, but unfortunately, I couldn't. I will definitely make a video on prefetch_related very soon, I planned it earlier, but somehow I got into some other videos. Sorry for the inconvenience caused.😔
@RedElectrik
@RedElectrik 4 жыл бұрын
Probs still a good idea to remove that out the title
@CodeBand
@CodeBand 4 жыл бұрын
I have done the video of prefetch_related.😊 I also discuss when to use prefetch_related or select_related and their differences in the video. Please do let me know your suggestions in the comments. Thank you☺️ kzbin.info/www/bejne/a164f2ePhal3h8U
@RedElectrik
@RedElectrik 4 жыл бұрын
@@CodeBand I mean the title for this is still prefetch_related. Seems somewhat misleading
@misfarsiddeek3105
@misfarsiddeek3105 4 жыл бұрын
Hi. Great brother. May know that what is the different between mentioning Foreignkey, many to many and one to many in our model? Are they same?
@CodeBand
@CodeBand 4 жыл бұрын
Thanks a lot brother...and about mentioning the foreign key and all, it totally depends on what kind of relationship you wanna use... I recommend you to watch this playlist...you will get a better idea... kzbin.info/aero/PLbasZIkCgHJH38p2WkC5GTsgoV_8hlQ4A And also please refer this article... hackernoon.com/django-orm-relationships-cheat-sheet-14433d6cf68c
@misfarsiddeek3105
@misfarsiddeek3105 4 жыл бұрын
@@CodeBand ok brother. I will refer these and ask from u if I have doubts. Thanx for helping me to learn django.
@CodeBand
@CodeBand 4 жыл бұрын
@@misfarsiddeek3105 It's my pleasure brother...I will definitely help you out in case...Thanks :)
@misfarsiddeek3105
@misfarsiddeek3105 4 жыл бұрын
@@CodeBand thnx brother. ❤️
@CodeBand
@CodeBand 4 жыл бұрын
@@misfarsiddeek3105 Welcome brother..:)
@pankaj9575
@pankaj9575 3 жыл бұрын
Getting error while migrations, Cannot add or update a child row,a foreign key constraint fails
@CodeBand
@CodeBand 3 жыл бұрын
Please post your models.py so that I could help...😊
@abhisharma8526
@abhisharma8526 4 жыл бұрын
hello sir ...please make a video of prefetch_related today...it's urgent for me ....please
@CodeBand
@CodeBand 4 жыл бұрын
I'm very sorry...I have not scheduled any video for today...but I can assure, the next video is prefetch_related. Meanwhile, you can refer other resources. Thank you for the support😊
@CodeBand
@CodeBand 4 жыл бұрын
I have done the video of prefetch_related.😊 kzbin.info/www/bejne/a164f2ePhal3h8U
@deepanshuaggarwal7042
@deepanshuaggarwal7042 3 жыл бұрын
we can use select_related only in ForeignKey case? or we can use with other joins also
@CodeBand
@CodeBand 3 жыл бұрын
select_related is limited to single-valued relationships - foreign key and one-to-one. For more clarification, please see this post in SO. stackoverflow.com/questions/31237042/whats-the-difference-between-select-related-and-prefetch-related-in-django-orm
@rojanshrestha822
@rojanshrestha822 4 жыл бұрын
Thanks!! By the way, where is the video on prefetch_related??
@CodeBand
@CodeBand 4 жыл бұрын
Glad it was helpful. I will actually do the prefetch_related in a future video... :) Thank you :)
@CodeBand
@CodeBand 4 жыл бұрын
I have done the video of prefetch_related.😊 I also discuss when to use prefetch_related or select_related and their differences in the video. Please do let me know your suggestions in the comments. Thank you☺️ kzbin.info/www/bejne/a164f2ePhal3h8U
@paranoia9142
@paranoia9142 2 жыл бұрын
Will this work on 3 models?
@CodeBand
@CodeBand 2 жыл бұрын
You can use __(double underscores) to access related field, see this : stackoverflow.com/questions/19909672/django-prefetch-related-on-multiple-models
@RedElectrik
@RedElectrik 4 жыл бұрын
You gonna remove "prefetch_related" for the title yet?
@CodeBand
@CodeBand 4 жыл бұрын
I'm planning to do the next video in prefetch_related, so that I could put up both of them as a playlist and hence it would not be a big issue. Please let me know your view on this😊
@CodeBand
@CodeBand 4 жыл бұрын
I have done the video of prefetch_related.😊 I also discuss when to use prefetch_related or select_related and their differences in the video. Please do let me know your suggestions in the comments. Thank you☺️ kzbin.info/www/bejne/a164f2ePhal3h8U
@flowing_dance
@flowing_dance 4 жыл бұрын
why people use fake accent ..its so irritating!
@CodeBand
@CodeBand 4 жыл бұрын
Sorry to hear that...Honestly, it's not made up...its original😊
Мы сделали гигантские сухарики!  #большаяеда
00:44
Matching Picture Challenge with Alfredo Larin's family! 👍
00:37
BigSchool
Рет қаралды 52 МЛН
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 6 МЛН
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 356 М.
Understanding Django Model Relationships
25:56
Pretty Printed
Рет қаралды 94 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
Django Multiple Database Setup Ex1
32:51
Very Academy
Рет қаралды 37 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 193 М.
How to Use Select Related and Prefetch Related in Django
9:34
Pretty Printed
Рет қаралды 27 М.
Python RAG Tutorial (with Local LLMs): AI For Your PDFs
21:33
pixegami
Рет қаралды 219 М.
Is Drizzle Really Better Than Prisma?
20:15
Web Dev Simplified
Рет қаралды 79 М.
Мы сделали гигантские сухарики!  #большаяеда
00:44