CS50W - Lecture 4 - SQL, Models and Migrations

Поделиться
HTML-код
  • Опубликовано: 23 сен 2024

Комментарии • 268

  • @larjasoul
    @larjasoul 3 года назад +149

    I actually can't tell if Django is hard or not.
    This man explains topics so clearly; I'm convinced he could teach me Hebrew in 8 minutes.

    • @sitalsitoula6536
      @sitalsitoula6536 2 года назад +6

      It's actually pretty basic stuff that he is teaching. That's why it feels easy.

    • @StevenSenjaya
      @StevenSenjaya Год назад +5

      and here I am, still strugling even learning on these "easy" topics, especially the previous one about Django 😬

    • @tainarapalmeira4526
      @tainarapalmeira4526 Год назад +6

      @@StevenSenjaya hey there, don't worry about it, just keep studying :)) you'll make it

    • @jancejose2716
      @jancejose2716 Год назад +7

      @@StevenSenjaya
      Dear Bro ,
      Teacher is a great man . Kindly Hear Each one 10 times . Then write Note . Then execute in computer . Try a new App

    • @ianblanc7793
      @ianblanc7793 11 месяцев назад

      @@jancejose2716 10 is kinda crazy, 3 should be way enough

  • @Grimwood_
    @Grimwood_ 3 года назад +94

    I have never so easily sat through a 2 hour RUclips lecture as I have watching this! Amazingly displayed & taught. My CS teachers would always tell me Django is way too complicated and I'm shocked to see how high level and easy to grasp Django actually is!

  • @duska3529
    @duska3529 2 года назад +37

    Brian is best teacher I have ever witnessed in my lifetime... Nothing unnecessary, every single word he say has purpose to learn you topic in most efficient way possible..

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

      then you havene't seen much teahers

    • @hashimsulaiman6003
      @hashimsulaiman6003 8 месяцев назад

      me to I have seen many teachers but Brian is different there is a way he connects one section to the other that makes you get a relationship and he explains had topics in avery simple and inteructive way that you visualise how everything comes about@@shubhamraj25

  • @preyankjain5494
    @preyankjain5494 Год назад +20

    46:00 start of flights django project
    49:52 models.py
    53:00 python manage.py shell
    56:21 string representation of model function
    59:00 linking two models
    1:07:00 index.html for loop using the models
    1:12:08 creating admin acc in django
    1:17:00 adding functions to manipulate data in views.py
    1:23:00 adding if empty clause using django in an html file
    1:28:00 getting particular data from POST request
    1:32:00 dropdown list in html
    1:33:56 exclude passengers from a query
    1:38:13 configure admin page
    1:41:00 add/manage users (login)
    1:49:00 authenticate user with username and password
    1:51:00 access username in html from django
    1:52:39 logout

  • @alseynidiop8650
    @alseynidiop8650 3 года назад +26

    This course makes me shift from PHP to Django.
    This guys is a genius.

  • @donteo3105
    @donteo3105 3 года назад +34

    Brian is awesome, a precious gem in teaching profession, learn much from his teaching in one video which could take years... thanks Brian, hoping you can share more & help more people to acquire Tech Skills!

  • @udz26
    @udz26 4 года назад +76

    This one hit hard.
    Edit: Yes, the lecture had too much info, but as you start working on 1st part of the project, everything after that feels natural and fun to work on.

    • @sumitrana1652
      @sumitrana1652 4 года назад +16

      too much to digest in a single go xD

    • @innocence3158
      @innocence3158 4 года назад +6

      damn I agree

    • @Wtizreal
      @Wtizreal 4 года назад +13

      somtimes u gtta watch it a few times or watch it from a diff source.

    • @johndowney47
      @johndowney47 3 года назад +1

      I took CS50 and this is an extension of that course

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

      Remember that these lectures were accompanied by Homework ... the lecture just prepares you for that solitary task. Watch the lectures, then find the original assignments (or an approximation).

  • @Vhc706
    @Vhc706 6 месяцев назад +2

    Awesome lecture on a difficult topic! This is the type of video you have to watch over and over because it's so dense. He doesn't waste a single second.

  • @tinashe6383
    @tinashe6383 3 года назад +24

    brian is a naturally talented teacher he teaches great things in a short time

  • @NaifAlqahtani
    @NaifAlqahtani 3 года назад +29

    Despite my knowledge in SQL from cs50x, which saved me the first 55 minutes of the video, I still need to rewatch and practice everything past that in this week's lecture.

  • @Biikashkumar
    @Biikashkumar Год назад +4

    What we need in this world is teacher like Brian and David who could articulate even the most complex languge and topic to a level that even the newborn could understand 😀. Thank you.

  • @SUBZERO8134
    @SUBZERO8134 Год назад +5

    i was afraid i couldnt understand a full course in english but brian has an easy pronunciation and teaching skill,terrific class

  • @alburnto
    @alburnto 3 года назад +5

    Holy sh-. This lecture made me more interested in Django than the previous one. The ORM blew my mind. Thanks!

  • @MehediHasan-xd6rj
    @MehediHasan-xd6rj 2 месяца назад

    Their videos are well-directed and they know how to make complex topics as simple as possible, making them impossible to ignore. Thank you, Brian.

  • @syeda.k.2934
    @syeda.k.2934 3 года назад +288

    Brian teaches in 2 hrs what paid courses teach in 2 months

  • @alanyang4019
    @alanyang4019 3 года назад +6

    Thank you Prof. David J. Malan and Brian.

  • @R0b3
    @R0b3 Год назад +3

    I've developed four application with Laravel Framwork, but now I've realized, this framework is amazing!!! I'm going to dev with this

    • @Degenerated00
      @Degenerated00 8 месяцев назад

      How's it going? How's it compared to Laravel?

  • @WaiSanLee
    @WaiSanLee 2 года назад +19

    These lectures are fantastic, but Brian is such a bloody fast typer that every time he gets to a section where he's coding I have to set the speed to 0.25 to try and code along, and even then he's faster than me!

    • @usmankraja
      @usmankraja 2 года назад +4

      At one time I thought he was faking the typing and it was being auto generated that's how fast his typing speed is 🤯

    • @anaveronicaaponte
      @anaveronicaaponte Год назад +4

      I have to pause the video every time so I can code along as well lol

    • @thomasmoncrief26
      @thomasmoncrief26 10 месяцев назад +2

      For Brian it was a two-hour lecture. For me, it lasted eight hours.

  • @hashimsulaiman6003
    @hashimsulaiman6003 8 месяцев назад

    I have seen many teachers but Brian is different there is a way he connects one section to the other that makes you get a relationship and he explains had topics in avery simple and inteructive way that you visualise how everything comes about.with this course he has tought me what I have been struggling for six month in just hours.had I began with you I would be miles away
    Thanks Brian

  • @thomasmoncrief26
    @thomasmoncrief26 11 месяцев назад +4

    Brian goin full beast mode in this one.

    • @khanhduluong4355
      @khanhduluong4355 10 месяцев назад +1

      Brian and also David are good teachers. The CS50 include CS50x and CS50w are absolutely masterpiece!

    • @stacy3781
      @stacy3781 2 месяца назад

      Spot on. Brian really shines here! I know nothing about SQL, but I'm enjoying my time here. He makes a 2-hour lecture fly by so fast!

  • @VinaySharma-sm4dt
    @VinaySharma-sm4dt 3 года назад +6

    Thank you CS50 for this amazing lecture.

  • @russelpeter2814
    @russelpeter2814 2 года назад +2

    Amazing stuff, Brian. You made my Django learning experience so easy & smooth!

  • @billionairesbio
    @billionairesbio 2 года назад +7

    Now i am getting somewhere since its a little confusing ... it was a awesome lecture, you sir brian 👌

  • @pra6in
    @pra6in 4 года назад +6

    The information here is so dense .

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

    I would recommend taking cs50x before this. Lots of information in this video that assumes you know certain things about python and programming in general. I was able to get through only because of cs50 and the amount of time i put into my final project for cs50. Django seems to have alot more built-in features than Flask or i just don't know flask well enough to use all the features and modules that come with it.

  • @Ammarkoka
    @Ammarkoka 3 года назад +4

    I need brian yu the only teacher in my whole life amazing teaching skills man loved it 😍🔥💯

  • @DMxalava
    @DMxalava 3 года назад +2

    Thank you, Brian, Harvard, and whole Harvard CS50W crew!

  • @Programming-w7s
    @Programming-w7s 11 месяцев назад

    Викладач чудово пояснює тему. Рекомендую

  • @christian37ism
    @christian37ism 2 года назад +4

    Django's feature of writing sql commands for the user is such a time saver. Just to add a row of data to a table can be tedious. And of course Python's language is more simpler and easier to use for dealing with Django's database.

  • @omar5695
    @omar5695 3 года назад +4

    Awesome! Thank you! I really love CS50W

  • @blackholesun4942
    @blackholesun4942 12 дней назад

    Deleting the first database entry isnt optional. Not doing some crashes the later code.
    01:15:41 there was a cut here. The flight from paris to new york was added off camera. I hope this wont break things

  • @innocence3158
    @innocence3158 4 года назад +4

    The content that is being provided here is just unique

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

    Thanks for the lecture. Covered a lot of information, that's for sure. Django is definitely powerful. I like the admin interface, very convenient. I like how it connects to a SQLite database by default and abstracts away the SQL statements.
    But I can also see how beginners would get totally lost. I would classify the subject material as intermediate to advanced. You need a good foundation in SQL, Python and object-oriented programming to keep up.

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

    very well explained. prolly the best tutorial on youtube

  • @evachen8623
    @evachen8623 7 месяцев назад

    Such a nice lecture, thank you Brian and the whole teaching team.

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

    It was so good I exited fullscreen like 10 times because of the sudden urge to like the video

  •  8 дней назад

    I am not a student. I know these already very well. Still, watching him is a joy 😅 💯

  • @s28177
    @s28177 3 года назад +1

    Love this energy. Thank you, Brian!

  • @abdounet8194
    @abdounet8194 3 месяца назад

    Best coding tuto a ever watch

  • @Daninshit
    @Daninshit 3 года назад +2

    Brian is on x2 mode. 🔥

  • @tornjak096
    @tornjak096 Год назад +2

    at 39:51 I think he needs to include additional JOIN query where he needs to join people table also to be able to include data about first name etc...

  • @skystar7350
    @skystar7350 3 года назад +3

    wow, maybe must takes a time to practice this so I can remember this lecture

  • @muzammilomarzoy6616
    @muzammilomarzoy6616 9 месяцев назад +1

    00:30:16 - Joining Tables

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

    Why use plain HTML forms in this lecture instead of Django forms, like in the previous one? What is each one's advantage and disadvantage or their respective use cases?

  • @GCKteamKrispy
    @GCKteamKrispy Год назад +2

    17:50 - create SQLite database
    47:36 - Django airlines app

  • @clunkeys
    @clunkeys 2 года назад +2

    45:45 Race conditions - Transactions

  • @sayori3939
    @sayori3939 Год назад +3

    After testing a bit i found out that __str__ method is how your admin page actually shows each row in a table!

  • @abteyeb7969
    @abteyeb7969 2 года назад

    high quallity of education from the best in internet

  • @oyekanmibamidele6196
    @oyekanmibamidele6196 2 года назад +1

    What a great guy you're!

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

    Thanks Alot ,this is the best channel to learn from

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

    the commands is not working properly in windows.

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

    59:00 he defines a foreign key to the model airport, but not to a specific column of the table, this means that is foreign key to any matchig string (code or city) ?

  • @Mizuh4
    @Mizuh4 2 месяца назад

    The Flight Table keeps incrementing from the last highest id value. I tried “ALTER TABLE Flight AUTO_INCREMENT = 1;” on the dbshell but all I get is Parse Error.

  • @w1llow01
    @w1llow01 3 года назад +4

    I get this error when I click submit to add a passenger to the flight @ 01:36:31
    TypeError at /flights/2/book
    Value after * must be an iterable, not int

    • @w1llow01
      @w1llow01 3 года назад +2

      it was a typo in return HttpResponseRedirect(reverse("flight", args=[flight_id])) had to use args=[] not args=()

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

      @@w1llow01 I think you can pass it as a list [] or as a tuple, but if you type just (flight_id), it takes it just as if it didn't have the parenthesis. You have to add a comma to make it a tuple, like (flight_id, ).

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

    Zakaria Jaddad was here, thanks to Mr Brain for this clear lecture🤍

  • @thanhhiennguyen8219
    @thanhhiennguyen8219 3 года назад +2

    I'm stuck with this, can anyone help me with the lecture:
    Using the URLconf defined in airline.urls, Django tried these URL patterns, in this order:
    admin/
    flights/
    users/ [name='index']
    users/ login [name='login']
    users/ logout [name='logout']
    The current path, users/login/, didn’t match any of these.
    I checked the settings & urls from airline already :

  • @gagikkhalafyan8731
    @gagikkhalafyan8731 9 месяцев назад

    Thank you! Absolutely stunning lecture.

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

    1:25:00 booking a flight

  • @Wholiganu
    @Wholiganu 2 года назад +1

    He didnt write anything in the urlpattterns of urls.py in flights, i get errors when migrating, how come he left the field empty and his migration worked?

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

    This Lectures worth on 0.75x. Man he is too fast. Machine

  • @jamilovalisher6865
    @jamilovalisher6865 2 года назад

    Brian you've started to grow on me

  • @jerichoserr1479
    @jerichoserr1479 10 месяцев назад +1

    OOP is strong in this one.

  • @joshuafranknjau2465
    @joshuafranknjau2465 3 года назад

    Great work, Brian Yu.

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

    Me listening to Brian: "This is a piece of cake"
    Me using Django: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

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

    At 1:36:09 I am getting NoReverseMatch at /flights/1 Reverse for 'book' with arguments '(1,)' not found. 1 pattern(s) tried: ['flights/

  • @wade3696
    @wade3696 6 месяцев назад

    I tried following along typing the code, but can't type as fast as Brian lol. Luckily he explains everything well.

  • @imtoolazytothinkofaname7127
    @imtoolazytothinkofaname7127 4 года назад +6

    at 1:30:18, when he types args=(flight.id,) why is there a need for the comma after the flight.id?

    • @TheBluntxX
      @TheBluntxX 4 года назад +8

      Because "args" refers to the tuple. If you create tuple with one element only then you have to include the comma.

    • @abhinav1025
      @abhinav1025 3 года назад

      u must have got this error, Value after * must be an iterable, not int

  • @nawafEalharbi
    @nawafEalharbi 2 года назад +1

    What is the name of song it's so gerogus

  • @oruchkin
    @oruchkin 3 года назад +1

    1:15:22
    there is TWO Flights, than you add 1 new Flight from Shanghai to Paris
    than you go on /flights/ page and we see FOUR flights - BUSTED (2+1=3) not four
    so it's all done not in one frame
    CS50 team, i appreciate your work here! You've done great material, i love it

    • @anaveronicaaponte
      @anaveronicaaponte Год назад +2

      Yeah I think this is the edited version of the live class

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

      Yes, the video was definitely edited. If you watch closely you'll notice the discontinuity.
      Probably to save time? As he's just repeating the adding of flights into the database.
      Very keen eye though! Somebody was paying attention, lol.

  • @marzenah123
    @marzenah123 3 года назад

    Fantastic lecture. Thank you!

  • @joesilva3519
    @joesilva3519 3 года назад +1

    The lecture is really good. There is some artifacting on the video however.

  • @Rohit-ed7ou
    @Rohit-ed7ou 3 года назад

    I have an question, that when I'm trying to run sqllite in terminal(vs code , windows) it shows sqlite is not recognised as an internal or external command so how to fix it ?

  • @alexcampbell-black8543
    @alexcampbell-black8543 4 месяца назад

    On Windows use single quotes for the SQLite queries otherwise it won't work

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

    at 1:03:19 i am having an error saying "Cannot assign "'jfk'": "Flight.origin" must be a "Airport" instance." Can anyone help?

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

      you have to deleteit from the database before you migrate. watch the video again, he did that at 57:49

  • @warzonetroll79
    @warzonetroll79 Год назад +2

    1:01:51: is he ok???

  • @pra6in
    @pra6in 4 года назад +2

    At 55:02 while saving it says, a lot of lines...and " no such table :flights_flight".I have checked it and repeated it 10 times stilll..can anyone help.

    • @pra6in
      @pra6in 4 года назад +2

      Don't worry ,I solved it myself.It was my mistake.

  • @theblackelephant
    @theblackelephant 2 года назад

    Brain you are a genius

  • @omeranbasuhai7577
    @omeranbasuhai7577 3 года назад +2

    when i write in my Trimina % touch flight.sql ....its tell me ('touch' is not recognized as an internal or external command,
    operable program or batch file.) how can help me please.

    • @nkimbasalim2715
      @nkimbasalim2715 3 года назад

      same for me here. I used '.open C:/Users/Nkimba/OneDrive/Skrivbord/SQL/flights.db'. For your case use ' .open flight.db '

    • @batuhandemir2347
      @batuhandemir2347 3 года назад

      That's because you are using Windows Powershell terminal. "touch" command is a bash terminal command which is available in MacOS and Linux by default. Use this in Windows: ni flight.sql

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

      That's because in your system "touch" doesn't exist, if you're using windows i believe you can just use the "code flight.sql" or even make a new file with your mouse (name it properly) then edit as text

  • @haojunchen8381
    @haojunchen8381 2 года назад

    absoultelly savior

  • @sunnie8460
    @sunnie8460 3 года назад +2

    1:30:25 Why the tuple here after `HttpResponseRedirect(reverse('flight', args=(flight.id, )))` there has to be a , after fight.id ? Without the , it showed error.

    • @charlielin188
      @charlielin188 3 года назад +1

      ('a') is equivalent to 'a' in python. if there is no comma, python will think that u accidentally add a parentheses, so it will ignore the parentheses.

    • @koushikvss7638
      @koushikvss7638 3 года назад

      @@charlielin188 Hey, my form is not redirecting me to the page nor is it adding passengers to the given flight, pls help me

    • @charlielin188
      @charlielin188 3 года назад

      @@koushikvss7638What is the code inside ur view?

    • @koushikvss7638
      @koushikvss7638 3 года назад

      @@charlielin188 I made some changes to the code and now when I click the submit button, I get the same error page but when I reload flights/1, the passenger gets added. I will send the code in a few mins

    • @charlielin188
      @charlielin188 3 года назад

      @@koushikvss7638 What does the error page say?

  • @jrgen9645
    @jrgen9645 2 года назад

    But what if you want to add a logged in user as a passanger and only print that?

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

    WoW 😲😲😲 my brain trembles!

  • @manutmustudent727
    @manutmustudent727 3 года назад

    he is freaking awesome ...................................

  • @MaheshKumar-bg5re
    @MaheshKumar-bg5re 6 месяцев назад

    How does he type so fast? SELECT(capital) * FROM(captial) flights(suddenly lowercase letters); Everything in a fraction of second/...

  • @sandro235
    @sandro235 2 года назад

    I created superuser but can not login with correct password and user, it says "Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive."
    Please somebody help me. Thanks in advance.

  • @danielmihajlovski
    @danielmihajlovski 5 месяцев назад

    1:35:41
    ImproperlyConfigured: URL route '' uses parameter name 'flight_id/book' which isn't a valid Python identifier.
    Solution?

    • @ntwananomazibuko765
      @ntwananomazibuko765 5 месяцев назад

      Did you manage to get that sorted?

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

      @@ntwananomazibuko765 typo, this is the correct code. book. The position of ">"

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

    why you made the file .sql instead of .db?

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

    he is very good

  • @evone1583
    @evone1583 3 года назад +1

    1:40:20 (Timestamp)

  • @not_amanullah
    @not_amanullah 6 месяцев назад

    thanks ❤

  • @begadelharazi2243
    @begadelharazi2243 3 года назад +7

    Anyone else get this error?
    django.db.utils.IntegrityError: The row in table 'flights_flight' with primary key '1' has an invalid foreign key: flights_flight.origin_id contains a value 'New York' that does not have a corresponding value in flights_airport.id.

    • @ayanabilothman
      @ayanabilothman 2 года назад +4

      Delete the created migrations files from the migrations folder except for the main one (__init__.py).
      In addition, delete the "db.sqlite3".
      After that remake the migrations.

    • @dmadalengoitia
      @dmadalengoitia 2 года назад

      @@ayanabilothman Thanks! It worked for me

    • @ayanabilothman
      @ayanabilothman 2 года назад +1

      @@dmadalengoitia welcome 🤗

    • @ayanabilothman
      @ayanabilothman 2 года назад

      @Shahan Ghani is there an error message ?

    • @rizwanriaz8706
      @rizwanriaz8706 2 года назад

      Yeah me too.. I googled and found a function delete() to delete the objects..

  • @weizhishi3270
    @weizhishi3270 3 года назад

    Many thanks

  • @chiragmadaan3255
    @chiragmadaan3255 3 года назад

    thankyou brian!

  • @supercluster847
    @supercluster847 2 года назад

    Thanks from Ukraine!

  • @sofiullahiqbalkiron6818
    @sofiullahiqbalkiron6818 3 года назад

    Awesome Just 💚💚💚

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

    quality content as always from cs50!

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

    did somebody got stuck on this lesson. The command "TOUCH" is not working on my windows cmd promt.

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

      Same problem. It seems that Tough is an Macbook command. I solve this by creating the "flights.sql" file manually.

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

      Touch only works for unix based systems, windows is not

  • @القيصرالكبير-ي9ذ
    @القيصرالكبير-ي9ذ 3 года назад

    This kid is miraculous

  • @iurymikaelsobraldossantos646
    @iurymikaelsobraldossantos646 2 года назад +2

    Amazing class but it really bothers me how Brian teaches most of the things backwards
    When teaching models he first goes to the url including the view, then he creates the view including the template, and then he creates the template. That's kinda confusing when learning these concepts for the first time
    But anyway, excellent class as always

  • @rizwanriaz8706
    @rizwanriaz8706 2 года назад

    How a passenger could be on multiple flights? 1:19:58 How it's many to many relationship? Many passengers could be on one flight and one flight can have (one to many) passengers.. So seems like a many to one relationship..

    • @levanivashadze
      @levanivashadze 2 года назад

      a passenger can be on many flights since often you have to transfer from one flight to another especially on long flights. So Many passengers can be on many flights

    • @rizwanriaz8706
      @rizwanriaz8706 2 года назад

      @@levanivashadze oh yeah thanks.. it's a possibility... Without an assumption, so it was a bit confusing for me..