Python Django Tutorial: Full-Featured Web App Part 5 - Database and Migrations

  Рет қаралды 673,888

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 937
@sleepychildkungfu
@sleepychildkungfu 6 жыл бұрын
Dude. If I ever make any money from web development I will throw some your way. You are the golden god of tutorials and I love you.
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@quasa0
@quasa0 6 жыл бұрын
Did you succeed?
@mohammadsamir2713
@mohammadsamir2713 5 жыл бұрын
me, too
@robertweisejr265
@robertweisejr265 5 жыл бұрын
I completely agree these tutorials are excellently put together. I have taken classes elsewhere and they are either too slow or too fast. Corey's pace and how he describes what is going on is outstanding throughout!
@augre-app
@augre-app 5 жыл бұрын
@@quasa0 lol
@congcuongnguyen413
@congcuongnguyen413 2 жыл бұрын
0:15 - object relational mapping - ORM 1:52 - create Post model 5:34 - ForeignKey 7:39 - make migrations after modify models.py 9:19 - have a look on SQL code that will be migrate 11:25 - why migration useful 12:05 - query database on shell 18:27 - __str__ method 24:41 - special query set of user model 28:11 - pass data from model into view 31:13 - template filter 34:52 - add Post model into admin page
@ishanpand3y
@ishanpand3y 4 жыл бұрын
sir this is the third series from you I'm learning. Actually I am regretting why I've not watched u earlier. THIS IS THE BEST OF THE BESTS CHANNELS on PYTHON. HUGE RESPECT TO YOU SIR... *from India import love*
@pAirA_
@pAirA_ 4 жыл бұрын
have to like this comment for the clever import statement
@rahulnandre4422
@rahulnandre4422 3 жыл бұрын
import love love.more()
@NilakshMalpotra
@NilakshMalpotra 3 жыл бұрын
@Anoop Janakar I'm glad :D
@harshitheya
@harshitheya Жыл бұрын
love.objects.all()
@Paul-Olkov
@Paul-Olkov Жыл бұрын
thanks, man. I'm russian and I 'm not strong enough in English. But I can understand almost 90% you say using subtitles! I wanna say that you have a very undestandable vocabulary and a very clear pronunciation! Thanks one more time!
@imblue2844
@imblue2844 10 ай бұрын
Watching this from Kazakhstan. First I tried to look up some good tutorials on the Russian youtube but they all were bad. Then decided to go on English youtube and found that gold.
@quannmtt3110
@quannmtt3110 5 жыл бұрын
This is the first one that I actually have to comment on. I haven’t done that before on KZbin. You are the master of explaining everything with simple words. Your tutorials are just gorgeous and outstanding. I remembered when I started learning Python almost 2 years ago, your tutorials helped me a lot. Really. Its amazing. Since then, I think I have recommended your channels to at least 4 people. You deserved much more views than the current stats. Thank you so much and wish you the best for everything you do in the future. I will always support you.
@coreyms
@coreyms 5 жыл бұрын
Thanks, Quan! I appreciate the comment
@ShashtriJi-en2gr
@ShashtriJi-en2gr Ай бұрын
Hiii Corey !!! It's 2024 end....and Let me tell you that your playlist is still a phenomenal asset that a student can have to learn django❤...Thank You So much
@joefanningartist
@joefanningartist 5 жыл бұрын
Thanks Corey, not everyone can afford education so thanks brother : )
@EOO-Stand
@EOO-Stand 4 жыл бұрын
leave alone afford, how about understand it too hahaha. This videos are great
@zeelsinojia1289
@zeelsinojia1289 4 жыл бұрын
Everyone: "World is going through pandemic!!!" Corey: "Let's clear the screen first" :) Love your tutorials and explanation man Keep it Up man
@agentNirmites
@agentNirmites 4 жыл бұрын
World is going through pandemic, and we both are learning django!
@guardkaiser9344
@guardkaiser9344 4 жыл бұрын
me three bradah
@agentNirmites
@agentNirmites 4 жыл бұрын
@@complex1511 ok, counter += 1 BTW great content here in this playlist... 👍
@shashanksharma7242
@shashanksharma7242 4 жыл бұрын
@@agentNirmites LOL increment the counter by 1.
@agentNirmites
@agentNirmites 4 жыл бұрын
@@shashanksharma7242 ok, my database says 5, is it correct ? I am using firebase 😂
@troyke
@troyke 6 ай бұрын
I'll admit, you have some pretty stiff competition: Codemy, Idently, Tech with Tim, etc, but I will have to say that you're the best Teacher on youtube! You go at the perfect pace! You explain things well, etc You really couldn't ask for more! My hat's off to you CoreyMS!
@anand_dudi
@anand_dudi 3 жыл бұрын
He made this video in 2018 in so depth not even today's youtuber makes these days
@ShahidKhan-er1sw
@ShahidKhan-er1sw 3 ай бұрын
That's the reason I'm watching 5 years old playlist.
@victorystocktv
@victorystocktv 4 жыл бұрын
00:59 we can represent our database structure as classes, those classes be called models 2:15 class POST(models.Model): inherit from models.model 5:10 default = timezone.now 9:20 makemigrations: before we actually run the migrate command, actually create this table in our database 10:50 models.py 파일 it wrote this back-end SQL for us (SQL 몰라도 됨. 그래서 편리함) Thank you
@raphaelokai5981
@raphaelokai5981 3 жыл бұрын
Your app must be installed first (inside the settings.py) In our case you'll include 'blog.apps.BlogConfig' in our INSTALLED_APPS tuple inside settings.py
@FreeStepTAYLOR
@FreeStepTAYLOR 6 жыл бұрын
I`ve been using PHP for quite a long time, a friend told me about django and python, and since ive started searching for tutorials, your channel is the best so far, congrats my man, you are a amazing teacher, keep up the good work, thank you so much
@mohamedelogail1992
@mohamedelogail1992 5 жыл бұрын
I agree with you cause I've been using PHP for a long time too, but Python and Django makes life easier for web apps, especially with an outstanding teacher like Corey
@kamrulahsan06
@kamrulahsan06 5 жыл бұрын
Agree, I've been using PHP for a long too. Now I am shifting to python and Corey's tutorial is the beast. I've followed enough python tutorial, read book but his tutorial best among others.
@prettycode4028
@prettycode4028 5 жыл бұрын
Bro, php is bad.
@Saradomin65
@Saradomin65 5 жыл бұрын
@@prettycode4028 Developing web apps with raw php is bad yeah, but working with frameworks like Laravel and CI makes it more easier. Though have to say, Python and Django just makes it more easier.
@raphaelpz
@raphaelpz 6 жыл бұрын
I am commenting here again to thank you for the amazing work you've done in sharing your extensive coding knowledge. Really impressed by how you make this all feel simple, it is a rare skill and requires total mastery of the subject matter of course... hats off.
@coreyms
@coreyms 6 жыл бұрын
Thanks! Glad you’re finding the videos helpful.
@troyke
@troyke 6 ай бұрын
5-20-2024 Created my very first database-driven website - thanks to YOU! Thank you!
@maureento5435
@maureento5435 4 жыл бұрын
These are hands down the BEST Django app tutorials I've seen. It's not just the poll app that we can easily make with the documentation, it's not just looking painstakingly through the documentation, and it's not some simple app! This is absolutely outstanding and so simply explained - I would not have been able to create this on my own without this guidance; Here's to creating a full-stack app on my own after this! ❤️
@Lumkoz
@Lumkoz 5 жыл бұрын
I cant stop, this guy bloody hell, angels come in disguise, shout out from South Africa, your my superman chap
@coreyms
@coreyms 5 жыл бұрын
Thanks! Glad you’re enjoying the series!
@mrmuranga
@mrmuranga 5 жыл бұрын
This lecture took me awhile, I re-watched it several times to understand BUT after everything its now very clear . How models relate to a database table and relevant fields... I would advise anyone watching this to not give up easily rather re-watch several times and try and grasp the concepts rather than cram.....Corey introduces a very interesting perspective here which i had not seen in a past django tutorial which is the django shell from where you can actually run queries ...its after this that you gained insights on e.g why we have the entry: Post.objects.all() within this function: def home(request): context = { 'posts': Post.objects.all() #Displaying all posts..refer to querying on django shell...it actually runs a query } return render(request,'blog/home.html',context) Great Stuff Corey !
@Fortyfester
@Fortyfester 5 жыл бұрын
I was also having a lot of difficulty until I downloaded a program that displayed the database contents onto a GUI. The thing that really threw me was how django refers to tables as models rather than as tables. Once I understood that we were just creating a new table inside of the database called (projectname_post) it all began to make a lot more sense.
@masonqian6964
@masonqian6964 4 жыл бұрын
having some database knowledge really helps here
@SzymonRuszała
@SzymonRuszała 8 ай бұрын
I like how you present knowledge, it's far more easy to understand then reading the django book tutorial. Thanks
@toastrecon
@toastrecon 5 жыл бұрын
Awesome, Corey! Seriously never seen a more clear and yet comprehensive tutorial on the internet. Thank you.
@swatisrivastav5620
@swatisrivastav5620 4 жыл бұрын
You level of teaching is simply amazing. Thank God that someone like you exist.
@llewellynhattingh3496
@llewellynhattingh3496 4 жыл бұрын
You know what... I've BEEN trying to actually get whats up with Object Oriented Programming.. And now I finally do, this is super helpful especially in the workplace, thanks so much! I hesitated to watch a 40 min video, but it is every second worth it.. thanks Corey
@rxlvnd3397
@rxlvnd3397 4 жыл бұрын
I love you man. And for anyone who needs transcripts of these, you can click on the three little dots '...' next to the 'SAVE' option below the video, select open transcript, then copy and paste it anywhere you'd like. It helps to have a written version of the tutorials
@ogyrfiwargf
@ogyrfiwargf 3 жыл бұрын
Man, your free course is honestly better than a paid one I've finished recently. Way better.
@orkhanahmadov9963
@orkhanahmadov9963 3 жыл бұрын
This man is the best python developer and the best tutor I have ever seen... I learned Flask with him and without even visiting the Django documentation, I started watching these tutorials and now I feel like learning the core concepts of Django Framework. Thanks So much Corey !
@renejacques8288
@renejacques8288 4 жыл бұрын
Corey, I was always told and taught that ORM stood for object relational model, I believe. To me that was the hardest thing to understand. Now you say it's object relational mapper, it makes sense. It's a mapper; that's all there is to it.
@xtent2736
@xtent2736 4 жыл бұрын
I've been programming some backend for my startup's website, and let me just say, I appreciate your work. I honestly can't believe this golden resource is free. If my startup succeeds, I will make sure to send some money your way, because that's just how helpful this was
@Jam-iv6xz
@Jam-iv6xz 4 жыл бұрын
How has it gone?
@sahilamin219
@sahilamin219 4 жыл бұрын
You never need to say" this video is getting longer " just keep making them 🙋🙆🙌
@chandbing248
@chandbing248 5 жыл бұрын
Sir You are Great, I paid for Django course in Udemy even though i had some doubts, Thanks a lot for your detailed lecture, Now i got a confidece that I will become a gud django developer, all credits to you sir, Sure If got a job in django Sure I will pay my one month salary to you sir...
@coreyms
@coreyms 5 жыл бұрын
Thanks! Glad to hear you found the video helpful!
@gautamnair8886
@gautamnair8886 4 жыл бұрын
Wow thanks Corey. I guess you were recording this video in the middle of the night. 30:27. Thanks for working hard to get all the content out fast!!!
@Lucas-zd8hl
@Lucas-zd8hl 3 жыл бұрын
I think his computer uses the AM/PM system. Doesn't rule it out, though
@sethmanning6493
@sethmanning6493 3 жыл бұрын
django defaults to the utc timezone so he could have been in a different timezone
@ashayzemse7094
@ashayzemse7094 4 жыл бұрын
I've been searching for easy for Django Python for a month You are the best teacher Thankyou Sir from India
@unchiusm
@unchiusm 4 жыл бұрын
Corey, the work you are doing for the python community is amazing. You are setting a new standard for tutorials. Keep doing what you are doing because you are one of the best if not the best at it ! . Good luck to you and cheers!
@barkalez
@barkalez 5 жыл бұрын
I've been wanting to learn Django for 3 years, I've seen many courses on KZbin and none have approached me so I can understand, you're the only one who has. Thank you. I love you.
@Abhishek-yu4ys
@Abhishek-yu4ys 5 жыл бұрын
check out the durgasoft python and django course
@francescovecchio3931
@francescovecchio3931 5 жыл бұрын
I have virtually no experience in web application design technique. But your tutorial is introducing me to this world. A fabulous tutorial. Unfortunately, not having much practice with spoken English, I struggle to follow the phonic contribution of the course; but your teaching method makes up for my lack! Thank you! Francesco
@timeenough-l7b
@timeenough-l7b Жыл бұрын
past years i was on my undergrad class days,and you save me from datascience and now i am needing to learn more on website, you are my savoior to saving soem complex lesson to an easy way,thank you so much sir
@PolyRocketMatt
@PolyRocketMatt 5 жыл бұрын
The way you explain everything you do in careful details is just outstanding! No other tutorial on youtube actually got me pretty "fluent" if I could say so in Django. This tutorial did the trick. Thanks and keep up the work :)
@336_saranyamaity8
@336_saranyamaity8 3 жыл бұрын
This Django series is even better than the Flask one and easier to understand. And people say Flask is easy!! With Master Corey everything is easy !!!
@gregtuve1109
@gregtuve1109 5 жыл бұрын
You have a gift. You're the first channel I've ever supported on Patreon--at double the minimum level. It will be more if I can get my business a little further off the ground. I've never worked in programming, but I took a raft of programming courses 15 years ago. Back then, it was C++. Everything is better now--languages, frameworks, and tutorial videos (at least those by Schafer).
@coreyms
@coreyms 5 жыл бұрын
Thanks so much! That’s such a big help and I really appreciate it!
@florent9555
@florent9555 4 жыл бұрын
First guy that is actually explaining stuff in a structured way. Good job!
@dominicdit
@dominicdit 5 жыл бұрын
django is so powerful, coming from flask, django is the dream. thank you Corey, you are the best!
@md.bodruzzamansifat7357
@md.bodruzzamansifat7357 4 жыл бұрын
I really want to know who are these geniuses, who can dislike a video like this. If I had enough money, I would file a case in court against them. Thanks for this. You have my gratitude and respect. I will wait for your upcoming videos.
@perplexinginkslinger
@perplexinginkslinger 5 жыл бұрын
This is the best Django/python tutorial I've ever seen when it comes to shell/database. For the first time I actually understand this part of it! Again, thank you so much for providing this.
@skumarr53
@skumarr53 5 жыл бұрын
I thought web development was hard until I got introduced to this series. All I needed was a great teacher.
@igajohnbosco2428
@igajohnbosco2428 5 жыл бұрын
These are the best django tuts I have come across ever since i chose this django path. Surely I must contribute. You so on point. like you reading what my mind ever wanted
@kevinkrause6901
@kevinkrause6901 2 жыл бұрын
just started using python & django and cannot underline enough how awesome your videos are in terms of detail and understanding! Thanks!
@namesare4fools
@namesare4fools 5 жыл бұрын
GREATEST PYTHON & DJANGO TUTORIAL EVER.. I COULDNT FOUND ANY BETTER, EVEN PAID ONES
@pixmestudio
@pixmestudio 4 жыл бұрын
Best instructor on youtube. Amazing
@cugzarui5568
@cugzarui5568 3 жыл бұрын
33:35 putting a space between the colon and the string breaks it in case anyone was wondering
@blade722
@blade722 3 жыл бұрын
Thank you for this, I just encountered this problem and fixed it right away!
@vishwanathpujar8704
@vishwanathpujar8704 Жыл бұрын
Corey thank you very much.. I'm regretting why I didn't learn from your videos from beginning... Anyway never too late to learn things... THANK YOU
@Unclaimed3172
@Unclaimed3172 5 жыл бұрын
Coming from the Laravel framework, this is an easy transition for me to learn Python and its framework. Thank you for the great series
@pumpkinhead6646
@pumpkinhead6646 4 жыл бұрын
Laravel is sweet, but man I love python so much more than PHP
@janhitmejaari3850
@janhitmejaari3850 2 ай бұрын
Truly a gem on KZbin. Thanks a ton Corey for putting this up.
@DrYunfattpao
@DrYunfattpao 6 жыл бұрын
Great tutorial, thanks Corey! As a tip for anyone finding the python shell cumbersome, install ipython for a much nicer interface! It has auto-completion, colourisation and even highlights brackets. Just do 'pip install ipython' in your virtualenv and then run the shell normally ('python manage.py shell')
@lardosian
@lardosian 6 жыл бұрын
thanks man, i was actually wondering what ipython is, now i know!
@DrYunfattpao
@DrYunfattpao 6 жыл бұрын
@@lardosian no problem! ipython is really great to use
@markwilde5683
@markwilde5683 6 жыл бұрын
Thank you very much for the tip Mr Leaf. It feels and looks significantly better using ipython in the shell.
@karm0s304
@karm0s304 5 жыл бұрын
Thanks for the tip mate !
@EOO-Stand
@EOO-Stand 4 жыл бұрын
finally someone who makes django coding make sense. thank you again for your detailed, step by step tutorial.
@seantransformice
@seantransformice 5 жыл бұрын
You are an absolute god dude. Can't love your channel more. As soon as I can I'll get donations going your way, mark my words :) Thank you so much for this you have no idea how helpful your videos are!
@coreyms
@coreyms 5 жыл бұрын
Thanks!
@internetbuzz7143
@internetbuzz7143 3 жыл бұрын
Respect from INDIA. Great tutorials from you sir.
@Ledinos1
@Ledinos1 5 жыл бұрын
Thanks Core ;) Just started learning django, I'm coming from raw python. Your tutorials are so clear and easy to understand ;)
@Deddiward
@Deddiward 5 жыл бұрын
Man these tutorials are THE BEST you're very clear when you explain things. I tried to follow another tutorial from another channel but the guy was copy-pasting stuff and the video was kind of confusing. Thank you very much, you're helping me with a project I have to do for a university exam
@pradhvanbisht2177
@pradhvanbisht2177 6 жыл бұрын
I have been waiting for so long for you to release your Django course. I have been watching your python videos for a long time, doing a great job man :)
@srirajasingam8920
@srirajasingam8920 3 жыл бұрын
You are an absolute teaching god. You also must know your subject insanely well to teach it so precisely. Can't believe you only have 10K likes. This is so much better and more concise many more expensive paid courses.
@parthivijaya195
@parthivijaya195 4 жыл бұрын
Man! you're "code god "for me. The best tutor i've ever seen
@vincenttang6984
@vincenttang6984 5 жыл бұрын
I didn't realize how powerful and simple Django really is! Thanks for making these awesome tutorials
@gardenbrazil1959
@gardenbrazil1959 6 жыл бұрын
I'm very happy with your classes. Thanks a lot.
@erwinnovo3014
@erwinnovo3014 3 күн бұрын
You are an excellent teacher... You make Django like a simple technology to learn and use... Amazing... Kudos!
@sumanmalla9706
@sumanmalla9706 5 жыл бұрын
Thank You Sir !! Love from Nepal
@baky5372
@baky5372 2 жыл бұрын
MSuch a fantastic series even 4 years later. Thanks so much
@r.w.7267
@r.w.7267 4 жыл бұрын
I want to know we really appreciate all your hard word and content I will definitely sort you like the video and donate. Thank you sir!
@coreyms
@coreyms 4 жыл бұрын
Thanks!
@yachujoshi
@yachujoshi 4 жыл бұрын
The quality of this series is just top notch. You're literally making me love django!
@frclasso
@frclasso 5 жыл бұрын
Another amazing tutorial, You are the best one Corey.
@thiagonunes2751
@thiagonunes2751 2 жыл бұрын
Congratulations, you are the best teacher in KZbin. Thanks for all help!!!!
@andresfernandoaranda5498
@andresfernandoaranda5498 5 жыл бұрын
For those who get Post has no attribute 'objects' as an error in your IDE: This is because your IDE (vscode in my case) can't find it, doesn't mean it is an error and that it won't run. To avoid the error msg, you can: - Add to the 'Post' class (in models.py): objects = models.Manager() -- OR -- - Install pylint-django (Tutorial here for vscode: stackoverflow.com/a/47343542/4544940)
@TheAndrewMShow
@TheAndrewMShow 5 жыл бұрын
You sir are a lifesaver stuck on this forever till I decided to check the comments and found this!
@danielratner
@danielratner 5 жыл бұрын
I love you!!!! It took so long to solve this issue
@sivvie4993
@sivvie4993 6 жыл бұрын
I've watched many Django tutorials including the paid one but yours is the easiest to understand you did not skipped any details too! Impressive work and I've learnt a lot from your video, already support through Patreons, hope you're making more videos to help people!!! Can't express my appreciation but thank you so much!
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@matamatamata2604
@matamatamata2604 5 жыл бұрын
Great tutorials! Thanks for sharing this.
@przemeklelewski7608
@przemeklelewski7608 4 жыл бұрын
I tried to learn from other tutorials, but I failed. After 5 parts of your tutorial Corey, I'm still here. You have got a big knowledge and I wonder how to remember all you tought me...
@InsideElite
@InsideElite 5 жыл бұрын
wow django so similar to laravel thx for the great tutorials!
@jschvach
@jschvach 4 жыл бұрын
These are seriously GREAT tutorials. I can't believe these are free. You need to charge for these! I feel guilty that I'm receiving this quality of teaching for nothing, and you honestly deserve compensation. I will gladly contribute to your efforts. Again, just ecstatic I found your channel!
@unity_with_timoteo
@unity_with_timoteo 5 жыл бұрын
Hello Guys for those that have the message: The Post class dont has objects. Make it, put the code: objects = models.Manager(), in the Post class, below of author = models. .... Cheers!!!
@tamassimon7544
@tamassimon7544 5 жыл бұрын
OMG thank you so much!! Very helpful comment
@sprayzu
@sprayzu 5 жыл бұрын
To make it clear for everyone who has this issue .If you get this issue > Post.objects.all() this line instead of , then you should add objects = models.Manager() to models.py file - below author = models .
@barsonik3855
@barsonik3855 5 жыл бұрын
mine gives the same error even after doing that so no idea what ive done wrong lol
@sairammaddala9069
@sairammaddala9069 5 жыл бұрын
thanks so much. this was very helpful
@shaafijahangir9653
@shaafijahangir9653 4 жыл бұрын
@@barsonik3855 same, did you find a solution for it?
@AFunkyHypnoCat
@AFunkyHypnoCat 2 жыл бұрын
I DO NOT DESERVE THIS PLAYLIST THANK YOU
@XxSmAsHeN619xX
@XxSmAsHeN619xX 5 жыл бұрын
Who's here before 10 million views?
@zulfiqarabid2755
@zulfiqarabid2755 5 жыл бұрын
shittt... I missed it. wish I could be here before 10 mil
@hrushikeshvazurkar
@hrushikeshvazurkar 4 жыл бұрын
Next Level Tutorials Corey. You have reduced the learning curve for a lot of web development beginners like us. No one could have taught Django better.
@OtherSideMystery
@OtherSideMystery 2 жыл бұрын
To anyone who ran into this error: 'QuerySet' object has no attribute 'post_set' even though your model is named correctly, this might help when Corey defined the user attribute, he added .first() to the end of the code which made it no longer a QuerySet. If when you type user it says QuerySet infront of it, you need to redefine user and add .first() at the end like this: user = User.objects.filter(username='usernamehere').first()
@mudit2795
@mudit2795 5 жыл бұрын
Please change your sidebar settings. Download PackageResourceviewer> extract the package of the theme you are using> Pref > Browse Packages> go to the sublime theme file of your package> change the font size under the class sidebar_label. And thanks for this tutorial. Really appreciate it.
@josephralph7640
@josephralph7640 5 жыл бұрын
I have a doubt here. Is the constructor for the Post class autogenerated ? Since we did not create it, we just specified the field names in the class.
@david_9607
@david_9607 4 жыл бұрын
By far the best Django tutorial I've seen
@blahblahblah747
@blahblahblah747 4 жыл бұрын
once I get my job, ima donate to your patreon. cant do it now cause im broke af LOOOOl
@saakethch7416
@saakethch7416 6 жыл бұрын
to all of those who are asking doubts that the thier code isnt working plz try properly .. learn from these and not exactly write line to line .. the the code is perfect and dammn nice content explanation
@porametpathumsoot3286
@porametpathumsoot3286 5 жыл бұрын
Hello, I have a question, while trying to follow you and call Post.objects.all() its return error post has no ‘objects’ member. I tried to find solution online but nothing work out. What do I do wrong? I love your video. Thank you for the great jobs! Edited 20/06/2019 So after a while I check the SQL code and find out that the problem lies within this ... “auther_id” integer NULL REFERENCES... The actual message may not exact the same but this is cause when I mess up something about the field and when do a makemigrations or migrate, it ask me how to deal with something about change NOT NULL REFERENCES to be NULL how I choose so while thinking that it is some serious problem I add some code and now when I look at SQL it said integer NULL REFERENCES , THIS IS THE REAL PROBLEM. My solution is delete 0001 0002 or whatever its create and do it again while let the code handle it themself. Sorry if this dont help if you have similar problem.
@ivardu
@ivardu 5 жыл бұрын
Switch to Python Shell --> (django_env) E:\Projects\django_env_project>python manage.py shell Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) will result in error if you call before importing Post >>> Post.objects.all() class Traceback (most recent call last): File "", line 1, in NameError: name 'Post' is not defined >>> from blog.models import Post is giving me one result as I executed one already >>> Post.objects.all() >>> from django.contrib.auth.models import User >>> User.objects.first() Storing the user details in variable for passing in Post() class >>> var2 = User.objects.first() Storing the Post() obj to >>> post_2 = Post(title ='blog2', content ='Second post', author = var2) a variable post_2 When you call you will get no results in my only one result instead 2 >>> Post.objects.all() because you need to save the data to the database >>> post_2.save() >>> Post.objects.all() Now you see two results
@vladyslavkotov7570
@vladyslavkotov7570 2 жыл бұрын
stumbled across this channel some weeks ago, just devouring the content. Corey, your ability to explain is fantastic. thank you, thank you for this amazing gift. 11/10
@vishakbharadwaj1209
@vishakbharadwaj1209 5 жыл бұрын
Hi Corey. I have a question. How does the Post class know how to recognize something called author_id when you enter it? When we built the Post class in models.py, we never told it "If you get an author_id value recognise it to be user id and get the author name using that" Loving your series. Thanks a lot!
@TheReverseSide21
@TheReverseSide21 5 жыл бұрын
Good question, have the same one
@arp-p6k
@arp-p6k 5 жыл бұрын
having this issue too
@sallyaskar1159
@sallyaskar1159 5 жыл бұрын
@@arp-p6k Hi that is because when we create a table in Django referencing a foreign key, by default behind the scenes it will append _id to the name, so here we created a table called posts with some columns and then we referenced a foreign key and we called it author, once created Django will append _id to author so you can use author or author_id
@sallyaskar1159
@sallyaskar1159 5 жыл бұрын
Hi that is because when we create a table in Django referencing a foreign key, by default behind the scenes it will append _id to the name, so here we created a table called posts with some columns and then we referenced a foreign key and we called it author, once created Django will append _id to author so you can use author or author_id, another thing is that foreign keys are connected through their id so "If you get an author_id value recognise it to be user id " because we connect the two tables through the id of the user which is called author in the posts table
@deliciafernandes9946
@deliciafernandes9946 4 жыл бұрын
*HANDS DOWN THE BEST BEGINNERS GUIDE TO DJANGO!*
@KASANITEJ
@KASANITEJ 5 жыл бұрын
"Author_id" during creation of new row in the Post table... what is that?
@stanleyjohn4670
@stanleyjohn4670 5 жыл бұрын
I think it relates to the User table ids'. Since there is a foreign key in the Post table, the author_id shows the id reference for each user. Author_id is created automatically once a one-to-many relationship is made. I guess thats how it works
@mrmuranga
@mrmuranga 5 жыл бұрын
@@stanleyjohn4670 This was also confusing to me at first, by using author_id and assigning that to user.id , it essentially marries the user.id to a post....when you use the _id, django knows you want to associate this with a specific foreign key. There are also other ways to do this BUT Corey had already run a query to extract the user and assigned it to the variable - user...
@stanleyjohn4670
@stanleyjohn4670 5 жыл бұрын
@@mrmuranga Well. this is just one way of doing it. So choose what's comfortable lol
@rp2804
@rp2804 4 жыл бұрын
Since author is a ForeignKey to the Post model, Django knows to expect a User object. It just automatically adds the option to add the id for that foreign key also. So Django added that in the background. FROM COREYS ANSWER WAY BELOW >>> NOT MINE
@JonnyRootsDem
@JonnyRootsDem 3 жыл бұрын
You are the best Corey, for so long I've been wanting to use Python inside of browsers. I'm really grateful for the tutorials mate, i'm sure many others are too, thank you.
@orkish2844
@orkish2844 5 жыл бұрын
I wish I was born in the 1960s so I didn't have learn these arbitrary frameworks
@sante4940
@sante4940 4 жыл бұрын
I have just finished with this video-5th, Corey, I can surely tell you there are many who know technology but very few can present like you do. coming Monday 4th may 2020. i am starting with new Django project, I feel confident I can pull this off, thanks to your tutorials....
@cagriazcan7711
@cagriazcan7711 4 жыл бұрын
20% of my first webdev related pay check is gonna be yours. Thank you for this amazing tutorial.
@coreyms
@coreyms 4 жыл бұрын
Ah thanks! Best of luck!
@luvvermani1240
@luvvermani1240 4 жыл бұрын
Corey hoping you make it in google and he gets instant 2k in a day xD. Excellent series btw, if I ever get a job based on all this, I'll definitely pay as well, also a suggestion, do a good Django REST framework series, understanding API is proving to a challenge for me, I'm sure your series would help, me and countless others.
@waleedmashrequi5173
@waleedmashrequi5173 4 жыл бұрын
when I read Corey's comments it feels like he is narrating the line for me in my brain. I can literally hear his voice!
@amirshehzad3352
@amirshehzad3352 6 жыл бұрын
Like they say, teaching is an art. Thanks Corey Schafer for such wonderful tutorials. Waiting for more awesome playlists.
@life0verflowz
@life0verflowz 5 жыл бұрын
i am new beginner to python , and actually your tutorials made it so easy for me , you are the best :)
@oogieboogie7028
@oogieboogie7028 3 жыл бұрын
The best video on YT for understanding Django Models. Great work bro! Thanks a lot!!
@ayeshaansari2083
@ayeshaansari2083 4 жыл бұрын
If it is not for these tutorials it would have been very difficult for me to understand django. Every time a topic is covered in my class i first refer your channel. Your explanation is very clear and easy to understand👌. Thank you very much.
@appliedcomputerprogramming5206
@appliedcomputerprogramming5206 5 жыл бұрын
One of best django tutorials. Clear lucid deep knowledge
@egorkolobov2392
@egorkolobov2392 2 жыл бұрын
After a course of NestJS in my university, Django seems so cool, simple and straightforward. Many thanks for your videos, they are great!
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 18 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Python Django Tutorial: Full-Featured Web App Part 3 - Templates
45:45
Python OOP Tutorial 1: Classes and Instances
15:24
Corey Schafer
Рет қаралды 4,5 МЛН
Python Django 7 Hour Course
7:10:05
Traversy Media
Рет қаралды 1,8 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 18 МЛН