No video

Database Relationships | One To Many & Many to Many | Django (3.0) Crash Course Tutorials (pt 6)

  Рет қаралды 224,178

Dennis Ivy

Dennis Ivy

Күн бұрын

Check out my Complete Django course! dub.sh/NvGboTI
Introduction to Database model relationships. In this video we will be covering "One to Many" and "Many to Many" relationships and how this is implemented in Django.
Follow me on Twitter: / dennisivy11
Linkedin: / dennis-ivanov
Source code: github.com/div...

Пікірлер: 183
@DennisIvy
@DennisIvy Ай бұрын
Don't forget to check out my Complete Django course! dub.sh/NvGboTI
@AndreaManna85
@AndreaManna85 3 жыл бұрын
I'm italian and i already watch 2 courses in italian language. But just now with your course i start understand better django! You're really the best... thanks for all!
@apingsample4720
@apingsample4720 4 жыл бұрын
Your Visual representation of the relationship help us understand clearly, how i wish there are somethings like this in the Django documentation, it make things very easy! Thanks Dennis!
@ronanamelin
@ronanamelin 4 жыл бұрын
The principle was explained much better then most tutorials that are floating around. It`s structured and reproducible. +1 to your channel! Cheers!
@DennisIvy
@DennisIvy 4 жыл бұрын
I appreciate that Georgi :)
@parthjani8301
@parthjani8301 4 жыл бұрын
excellent explanations, keep uploading, love from India
@nurbektaizhanov4534
@nurbektaizhanov4534 3 жыл бұрын
+
@rafatulalam8677
@rafatulalam8677 4 жыл бұрын
Really good content Dennis. Can you make a future mini series on understanding model relationships in Django and at the same time explaining the concept of making good ER diagrams for any website project. There are not many videos out there covering these concepts in depth and you explain extremely well. It would be really helpful if you would consider making a series like that in the near future
@afelixalves
@afelixalves 3 жыл бұрын
I'm half way, but just need to say that this tutorial is way to great to be free... Premium content, without question!
@theanonymous92
@theanonymous92 9 ай бұрын
Great Video Thnx a lot for those who are super confused in the relations and then the code for relationships; I recommend watching this video again(and again) till your minds actually recognizes the pattern( you may take a break if you don't get it) BEST OF LUCK
@abdifatahwebdeveloper117
@abdifatahwebdeveloper117 3 жыл бұрын
I took many tutorials before this tutorial I have never seen like this one thanks million times dennis ivy
@gersoninthekitchen6656
@gersoninthekitchen6656 4 жыл бұрын
Thanks Dennis, you saved me £30,000 from University. I really appreciated.
@grandorigins6682
@grandorigins6682 3 жыл бұрын
Dennis, you make the best videos on Django. I am an engineer from South Africa. You are the most relatable coding youtuber to me. Keep making great content. It helps more than you know!!!
@yogeshyts
@yogeshyts 2 жыл бұрын
manytomany field is used when we need to connect an object with many objects of another table, Product can have multiple Tag like ice cream is product and summer,food are Tags.
@stevesamah4018
@stevesamah4018 4 жыл бұрын
This is super helpful I'm going to subscribe just because of this video.
@DennisIvy
@DennisIvy 4 жыл бұрын
So glad you found it helpful! I didn’t know if the drawings would make it more confusing but they seem to be helping :)
@akash4952
@akash4952 4 жыл бұрын
@@DennisIvy drawing did help us infact i understood that before building a long project, make a diagram .Thank you loving the course:-)
@akashpushkar306
@akashpushkar306 4 жыл бұрын
@@DennisIvy First of all, thanks for such amazing lectures you are taking. How can I load data in my UI and apply slicers/filters on the data from .csv files in the dashboard. Secondly, how can I take user input on the dashboard and run an ML model in the background and refresh the dashboard. Any link for tutorials would be really great.
@wethepeopleofghana8441
@wethepeopleofghana8441 4 жыл бұрын
This guy is now my go-to expect on most topics in Django. Dennis Ivy += 1 sub.
@mimishiba
@mimishiba 3 жыл бұрын
I did relational database for quite some time. Glad you corrected that Tags should be on Product and not on Order. It bothered me but I kept watching anyway cos I'm clueless with Django. Great series!
@jaumemontane3305
@jaumemontane3305 3 жыл бұрын
I finished an entire udemy course and made two project tutorials on it but I didn't understand this concept until this video and project. Thanks mate!
@adbeelomiunu
@adbeelomiunu 3 жыл бұрын
For whoever is following along with this video: Just in case you get stuck at the point where you can see the Tag section on the site go to admin.py file in your IDE and add it there so that it registers on the site just like he added those of Customer, Product and Order sections in the previous video on this playlist.
@ursoothesoul7705
@ursoothesoul7705 Жыл бұрын
Was just looking for this thanks pal
@danielkemmet2594
@danielkemmet2594 2 жыл бұрын
Hey Dude, Thanks for the video. Its helping me spin my own Ticketing System with DRF and PSU! 20$/mo back into my business's pocket!
@rboi
@rboi 4 жыл бұрын
i never really understood the intermediary table in the ManyToMany relationship until now, Thanks a lot for giving such a clear and easy to understand explanation!
@snowsenpai_
@snowsenpai_ 4 жыл бұрын
Best Django series I have ever seen 😍🔥super easy to understand💯
@rickykuo8360
@rickykuo8360 3 жыл бұрын
many thanks to Dennis!! this channel is really beginner friendly
@chaitanyasai2458
@chaitanyasai2458 4 жыл бұрын
Hi Dennis, I love your way of Explanation. could you please also do a video about how to add foreignkey relationship in modelforms and render both in single template? Where foreignkey value can be choosen automatically while filling the form
@AviralJain
@AviralJain 4 жыл бұрын
Excellent Explanations ! The first thing I do before watching your video is to like it ❤
@DennisIvy
@DennisIvy 4 жыл бұрын
Haha really appreciate the support! Glad these videos are so helpful :)
@vaishnavi4354
@vaishnavi4354 3 жыл бұрын
It's just awesome... I referred a lot videos for django. .but your series is awesome..no comparison 🙇🙇🙇🙇
@STU0408
@STU0408 6 ай бұрын
Thanks for the video. Very helpful! Does anybody know why the multiselect option is provided only on one side of the model in the admin panel if Many-To-Many is used? Theoretically it should be shown on both sides.
@i701Dev
@i701Dev 2 жыл бұрын
Can you do a follow up tutorial to this video explaining how to create a Model Form from the Order model?
@alcaravan555
@alcaravan555 3 жыл бұрын
Suggestion: press F7 and DOS window will display all the commands you entered previously
@achrafelkhanjari9157
@achrafelkhanjari9157 3 жыл бұрын
From Morocco cheers mate.
@raresduta1508
@raresduta1508 4 жыл бұрын
Thanks! Your free explanations are the best. Keep it like this
@murtazaahmad9559
@murtazaahmad9559 4 жыл бұрын
You are the best Teacher. Thanks for creating such videos.
@nomeshkumar6603
@nomeshkumar6603 3 жыл бұрын
Hey I understand the concept of many to many and one to many, the way you implement it I also do the same but I am unable to understand how many to many relationship data will we stored because we have not created any intermediate table and also I am unable to find it in my database.
@Adarsh8750
@Adarsh8750 4 жыл бұрын
You've put in lot of hard work on this Appreciation from India
@rayganmudberry375
@rayganmudberry375 4 жыл бұрын
please keep uploading awesome videos with great concept. thank you
@elmurodtadjibayev3212
@elmurodtadjibayev3212 4 жыл бұрын
Greatest videos about Django I've ever seen. Super Dennis.
@6ftofmisery636
@6ftofmisery636 4 жыл бұрын
Hey Dennis, I understand the logic behind one to many relationship for the customer but what if we have a large number of customers? don't you think a drop down feature would be slightly awkward?
@RaefetOuafiqo
@RaefetOuafiqo 3 жыл бұрын
that's just the default representations from admin-django if u want to search and get more out of field I thnk using the database in more helpful
@prasannadeshpande4435
@prasannadeshpande4435 2 жыл бұрын
Very good tutorial. Certainly deserves more subscribers and likes.
@omkarpatil4386
@omkarpatil4386 4 жыл бұрын
i didn't get why you write pending two times and out for delivery two times in tuple and thanks for your videos.
@rangabharath4253
@rangabharath4253 4 жыл бұрын
One is for key another is for value. Try it once changing the names of values
@michealwaldrup4357
@michealwaldrup4357 4 жыл бұрын
Explained differently. ('db_value', 'DB Value') The first is the actual value that will be entered in the DB (ie. 'db_value'). The second is the text representation of that value that will be shown in Django generated form inputs (ie. A select box with 'DB Value' as an option, when chosen will enter db_value into the database for that column.
@jhoniemusic
@jhoniemusic 4 жыл бұрын
soooo good.... nice. so if the Customer just cancel a ORDER that he or she made. the Order still on are database, as a Canceled ordered status, right??? sorry for my ENGLISH. but great Job.
@alexissuarezalvarez5622
@alexissuarezalvarez5622 3 жыл бұрын
Hello, I am not entirely clear why an order must be one to many with customer. a specific order is made by a customer.
@scottrowson
@scottrowson 3 жыл бұрын
Instead of have choices via a dropdown, is it possible to have checkboxes and allow multiple options to be chosen?
@ahmadjuuko352
@ahmadjuuko352 4 жыл бұрын
Very impressive explanation. But why don't you use cascade on delete so that the order made by a certain customer is also deleted when he is deleted to avoid orphaned entries
@mouadkerdoud9428
@mouadkerdoud9428 4 жыл бұрын
I don't get why products and orders don't have a ManyToMany relationship. A product could be in a relationship with many orders (as in, was ordered multiples times), on the other hand, an Order could have multiple products in it, and so multiple relationships ?
@vinnbrock
@vinnbrock 4 жыл бұрын
Denis Ivy , at 11:06, you mention changing the tags selection to a multi-select checkbox. I can't find where you do that in this video, or the next. Where/how do you change that? Also how could I change a dropdown option to radio buttons. BTW, thank you for awesome content!
@deepanshuyadavcs1379
@deepanshuyadavcs1379 2 жыл бұрын
I really appriciate your content. I have been stuck in this for a long time. Thanks Again✌️
@mikef6785
@mikef6785 3 жыл бұрын
Dennis at 11:11 you mention that you would be change the ManyToManyField to a checkbox in the admin. Did you ever get to that?
@LetCode96666
@LetCode96666 4 жыл бұрын
Some tutorials are goo, some are so good and well explained which is also easy to follow and then comes your videos! Perfect tutorials to learn from! Thanks a lot
@Alkik0
@Alkik0 4 жыл бұрын
Loud and clear, thanks mate !
@birukbringland4030
@birukbringland4030 3 жыл бұрын
five times i saw it is awesome
@JEBJOSH
@JEBJOSH 4 жыл бұрын
really helpful. The diagrams u draw and how you explain are rally helpful. thank you
@DennisIvy
@DennisIvy 4 жыл бұрын
I'm really glad those helped! I thought it might be distracting putting them in there so I'm glad they are working :)
@matthieuo39
@matthieuo39 4 жыл бұрын
Everything in this tutorial is awesome ! Your explanations are very good too. Thank you
@ivofrancisco357
@ivofrancisco357 3 жыл бұрын
Great explanations man. I've seen your in CodingPhase but never visited your channel. Now I'm a subscriber eheh.
@aidanali9483
@aidanali9483 3 жыл бұрын
Thanks! Hello from Kazakhstan!
@glennpotter4079
@glennpotter4079 2 жыл бұрын
Wow, great teacher!
@VijayKumar-dq3ph
@VijayKumar-dq3ph 2 жыл бұрын
Hi , do you have video explaining foreign key relations among tables of different databases or any hint on how to achieve that?
@k.m.jiaulislamjibon1443
@k.m.jiaulislamjibon1443 3 жыл бұрын
@Dennis Ivy.... Thanks for your journey of videos . It helping a lot. One more thing here you are adding selecting the Customer manually cause you are admin. But suppose when a customer orders a thing then in the order form can you plz show me way to select the user automatically to "Current User" where i have choices of users. thanks
@rayganmudberry375
@rayganmudberry375 4 жыл бұрын
Please upload one video daily. spread the knowledge. thank you
@DennisIvy
@DennisIvy 4 жыл бұрын
Uploading two right now :) had to reshoot yesterday’s because I didn’t like the way it turned out.
@rayganmudberry375
@rayganmudberry375 4 жыл бұрын
@@DennisIvy thank you.
@TheShadyStudios
@TheShadyStudios 4 жыл бұрын
You're a great teacher bro
@malharyadav3357
@malharyadav3357 2 жыл бұрын
I love this playlist and you really great at explaining the basics too! I had one question how does Django only ask for customer name specifically in order model like it access name column only what if we want to access another column from customer in order model?
@isaactonyloi2185
@isaactonyloi2185 3 жыл бұрын
Thank you Denis God bless you
@mrvalvet9856
@mrvalvet9856 3 жыл бұрын
Dennis, thank you for this useful tutorial! Easy to follow, well done!
@fowad27
@fowad27 3 жыл бұрын
I'm confused as to why you had to run migrate at 8:44 but not at 12:11, even though you made a change to the models.py file?
@svetliodoychinov5580
@svetliodoychinov5580 Жыл бұрын
Great video coming from FastAPI where you need to be doing more sql than python sometimes I am very surprised how simple the relations are in Django. It’s really cool.
@jorgeandrescruces7058
@jorgeandrescruces7058 3 жыл бұрын
Thanks for this content man. The quality is awesome
@akashpushkar306
@akashpushkar306 4 жыл бұрын
@Dennis Ivy: First of all, thanks for such amazing lectures you are taking. How can I load data in my UI and apply slicers/filters on the data from .csv files in the dashboard. Secondly, how can I take user input on the dashboard and run an ML model in the background and refresh the dashboard. Any link for tutorials would be really great.
@benjaminmensah5110
@benjaminmensah5110 4 жыл бұрын
I just watched this and am amazed. Thanks
@rockeraman15
@rockeraman15 3 жыл бұрын
Thanks a ton man, you made it so simple to understand
@abdurahmanyusuf5170
@abdurahmanyusuf5170 4 жыл бұрын
keep going amazing video sir thanks alot from somalia
@TheEaglesBasket
@TheEaglesBasket 3 жыл бұрын
If you delete a product, it will be null in the order. So it will be impossible to have a order history for a customer. And if you change a price of a product, then the order would not show the price when ordering. There must be a better way to do this?
@danielvaliente007
@danielvaliente007 3 жыл бұрын
Good morning , please is it possible to implement this many to many relationship and one to many relationship using mysql as my database
@davidbrown2806
@davidbrown2806 4 жыл бұрын
1. Why are the date_created fields not showing up in the Admin ? 2. Would be nice to have sqlite3 create Order Numbers sequentially automatically, and display.
@abinanto6394
@abinanto6394 2 жыл бұрын
what if there are 1000 customers and we need to add an order . how to select the customer
@ashrafulfuad2967
@ashrafulfuad2967 4 жыл бұрын
thank you sir really great explanation with good example
@johnsonvaughn2366
@johnsonvaughn2366 Жыл бұрын
How should I make more user friendly to many to many field in admin panel? TabularInline is not good when too many values in many to many field.What should I use?
@tehreemakhtar8652
@tehreemakhtar8652 Жыл бұрын
Don't you think that relationship between Orders and Products should be many to many because normally one order can contain multiple products. I'm a lil confused just because of this.
@felreizmeshinca7459
@felreizmeshinca7459 3 жыл бұрын
@12:15 Wait a minute, we don't have to makemigrations & migrate after changing the codes in models.py?
@rssvprasad9859
@rssvprasad9859 Жыл бұрын
why to create a new customer user name and email? how can I directly import already existing users from table and display on page model customers!
@khatibmahmud263
@khatibmahmud263 3 жыл бұрын
Boss of the Bosses
@tahmidbaquee1740
@tahmidbaquee1740 4 жыл бұрын
Hello Dennis, I understand the logic of the relationship between custormer and order(one to many) but I am confused about the relationship between product and order. Is it because a single product can have multiple orders in which case product will be the parent and orders will be children? By the way keep up the good work. Really enjoying your series.
@DennisIvy
@DennisIvy 4 жыл бұрын
Yes that's correct. A product is a type of item a store caries. But an order is just an instance of that product. Lets say a store holds the product of a "Bike". We need multiple customers to be able to Order a bike. So we can identify which product the customer ordered by looking at its parent.
@shagunmathur7611
@shagunmathur7611 3 жыл бұрын
@@DennisIvy What if there are multiple Products in a particular Order. Do we have to create many to many relationship between Order and Product Models?
@4MXW
@4MXW 2 жыл бұрын
@@shagunmathur7611 I think YES (by the way he selects multiple tags and it is also a ManyToManyField)
@fatmafilali3429
@fatmafilali3429 5 ай бұрын
Whenever I try to add a foreign key, it displays this error: 'Cannot add or update a child row: a foreign key constraint fails.Can you please help me?
@rdarktemplar1989
@rdarktemplar1989 3 жыл бұрын
i believe its missing a video about how to handle errors when trying to delete data from the web application instead of the given example from console and django admin
@trungle6039
@trungle6039 4 жыл бұрын
Hello Dennis, In fact, on each order buỷer can buy some products.so I used: product = models.ManyToManyField(Product). is it Ok ?
@julianamaya974
@julianamaya974 4 жыл бұрын
I think the same. An order could have many products.
@hamza-325
@hamza-325 4 жыл бұрын
It can be like that, but it is mandatory in Relational DBMS (database management systems) to simplify all many-to-many relations to one-to-many. However, Django seems to like simplifying things too much and not requiring this.
@brhh
@brhh 3 жыл бұрын
what if the customer was A user in the project's database?
@aavlasti
@aavlasti 4 жыл бұрын
The course is really great, but I have a question. Why we put the Tags class above the Product class? We can not just write it anywhere and access it? I mean why we need to have the order(not the Order class) in the code file? Is it just a preference from you? or it will not work otherwise?
@Magistrado1914
@Magistrado1914 4 жыл бұрын
Excellent course 11/07/2020
@SunPhanithVataNakE
@SunPhanithVataNakE Жыл бұрын
So How can we get data from Tage table ? like to display in home page
@ThePrashantsonu
@ThePrashantsonu 4 жыл бұрын
how to override from multi select option to multi checkbox
@devngecu
@devngecu 4 жыл бұрын
This may not be quite clear but i hope you understand: I have created my class models with the relationships addressed in this video.But every class requires the foreign key class to be predefined above it,making the whole process an infinite loop.How do i tackle this?
@user-ds6to3ly8i
@user-ds6to3ly8i 11 ай бұрын
I have one question following the link between Product and Order : Why don't we use ManyToManyField instead of One To many ? because in one order we can have many products and one product can appear in many orders .
@israelsamson5846
@israelsamson5846 9 ай бұрын
the logic is in order to order many products customer needs to order again and again b/c customer had 1 to many rln with the order so idealy there is a many to many rln between the customer and product
@diwasbasyal9882
@diwasbasyal9882 3 жыл бұрын
@Dennis why i get error while opening source code ..error like this Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail
@Modafinil
@Modafinil 4 жыл бұрын
I tried to form a primary key that would contain two fields. If I understood right the info I found from web, Django does not support such feature and it has been so for a long time. What could be so difficult/overwhelming to prevent to implement a common feature like that?
@CircuitNotion
@CircuitNotion 2 ай бұрын
very helpful bro!
@ursoothesoul7705
@ursoothesoul7705 Жыл бұрын
I'm getting an issue while adding data to order when i choose customer name it says Order object has no attribute name Seems like the foreign key is noy connecting anyone can help?
@wong1139
@wong1139 4 жыл бұрын
感谢您的教程,对我的学习很有帮助!
@juanignaciodominguez5902
@juanignaciodominguez5902 4 жыл бұрын
Great explanation! Thank you!
@bishaladhikari8691
@bishaladhikari8691 Жыл бұрын
why product and order have one to many relationship ?
@gowthamns8228
@gowthamns8228 4 жыл бұрын
Can you please explain how to join tables (inner join) the joining tables has no foreign key relationships in django orm and once join is happen how to serialize the data to create API?
@1a9Cj5
@1a9Cj5 3 жыл бұрын
Thanks for the excellent content. Though on 2:00 I think one product (ball) can have both Sports Tag and Summer Tag but then BBQ Grill can't have summer as a tag. It is one to many not one to one. Am I right?
@rangabharath4253
@rangabharath4253 4 жыл бұрын
Awesome as always bro
@evankadsouza8058
@evankadsouza8058 3 жыл бұрын
i had a doubt. can the orders be entered via the form given to the user too? instead of manually entering them in the db
@dislikebutton3509
@dislikebutton3509 Жыл бұрын
13:36 how can we change order name from 'Order object'
@AFuller2020
@AFuller2020 3 жыл бұрын
When did you load the models.py? Not in this course, should we imported into this course from another?
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 14 МЛН
Мы сделали гигантские сухарики!  #большаяеда
00:44
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 39 МЛН
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 356 М.
7 Database Paradigms
9:53
Fireship
Рет қаралды 1,6 МЛН
Understanding Django Model Relationships
25:56
Pretty Printed
Рет қаралды 94 М.
SQL Server Tutorial - One-to-many and many-to-many table relationships
9:51
Watch This Before Using Django With MongoDB
9:18
Dennis Ivy
Рет қаралды 43 М.