CS50W - Lecture 3 - Django

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

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

  • @staystealth
    @staystealth 2 года назад +88

    00:06:02 Django Project Setup
    00:12:42 First View
    00:14:19 Url setup
    00:20:47 Additional Views
    00:24:04 Parameterizing Views
    00:27:22 Templates
    00:43:40 If condition in templates
    00:48:03 Using static files
    00:53:39 Tasks App
    00:58:29 For loop in templates
    01:00:23 Adding tasks
    01:02:39 Extending templates
    01:09:45 Namespace Colision
    01:14:22 CSRF verification
    01:19:30 Django Forms
    01:24:32 Form Validation
    01:29:15 Django Redirect
    01:31:09 Sessions

  • @abdulwahabkhan1086
    @abdulwahabkhan1086 Год назад +35

    No words to appreciate this type of content available for free! Thank you so much for such engaging content CS50 team!

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

    1:11:53 - names collision
    1:14:40 - CSRF verification failed
    1:19:30 - Django's own ability to create forms
    1:29:15 - Django redirect

  • @way2ml
    @way2ml 2 года назад +53

    Brian is brilliant teacher. I wish I could explain things like him in the future.

  • @dudecurioux
    @dudecurioux 4 года назад +374

    Great lecture. l had to pause in between for him to rest a bit.

    • @TerriTerriHotSauce
      @TerriTerriHotSauce 4 года назад +9

      loll

    • @ABTV-UK
      @ABTV-UK 3 года назад +12

      How very thoughtful of you

    • @crazyboy-gw7rk
      @crazyboy-gw7rk 3 года назад +6

      Wow brother 🤣🤣

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

      😂😂😂😂

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

      Definitely worthy of being Mr.Malans trustee he is getting all the Great teacher vibezz on him

  • @kannigoud5435
    @kannigoud5435 4 года назад +42

    really cs50 changed my life

  • @sam-nc8zv
    @sam-nc8zv 3 года назад +88

    You might learn to code from anywhere but if you really want to clear your concepts about what really is happening.. CS50 is a must

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

      Are you referring to cs50x?

    • @sam-nc8zv
      @sam-nc8zv 2 года назад +1

      @@ObaidahNaseer yeah

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

      Yep. I did 3 weeks of CS50x and it carried me through my first 2 years of coding in college. Coming back now many years later to try web dev

  • @PelgayJamyang
    @PelgayJamyang 4 месяца назад +2

    Mr Brian is a Brillant teacher and the build up of the lesson apps is awesome,No wonder they produce whole new level of brillant pass out students with the teaching faculty and clarity of subject like this.Thank you so much Harvard and the biggest gift of our time " The internet".

  • @coreanoquant
    @coreanoquant 3 года назад +20

    This is way better than paid courses from Udemy. I don't know why I wasted so much money on rubbish courses when I could've just taken this course.

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

      never pay for a course when you can find it for free

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

      The best things in life are free lol

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

      @@lemon_maho The thing is, for a long time there were no courses like this for free.

  • @bayramalak2673
    @bayramalak2673 4 года назад +136

    Just give him some water for God sake!
    Great job dude. It is really what I need.

  • @cagri5360
    @cagri5360 4 года назад +42

    A very dense and totally meaningful course! Instead of wasting time on nonsense coding bootcamps (html, css, python and Django) here you see the total pure logic background and create totally generic pages, submit buttons that does something and things changes according to input... I loved and each 5 mins or so wanted to press on the like button (first time ever) :)))

  • @luciouswong1848
    @luciouswong1848 3 года назад +17

    Thank you CS50 for posting this super useful lecture! Brian has excellent delivery skills.

  • @Malithsen
    @Malithsen 3 года назад +21

    This is the best lecture I have taken on Django

  • @xx03_p19
    @xx03_p19 2 года назад +28

    Brian should have his own software development learning startup and expand the content not covered on cs50! He'll give a real treasure to this world and earn 100 of millions if not billions doing so!

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

    Brian is the best online teacher for me. i connect with his way of teaching so much that i understand everything he teaches so easily. i don't think i've enough words to thank him for this. God bless Brian

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

    Around 25 min, when you already have dedicated views for Brian and David then I think you should prioritize them in first and the generic greet view comes later only in defining URLs paths. This is not an error but makes different logical outputs.
    I am really thankful for your teaching.

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

      Could you explain what you mean by different logical outputs? Transforming RUclips into stackoverflow I know :D

  • @naguip91
    @naguip91 4 года назад +46

    Thank you for this!!! Brian and David are amazing teachers!!

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

    Omfg such good teacher, never stops, always knows what to say, tempo is just perfect, everything is so clear and you can easly follow along, congrats

  • @madhanganesh1
    @madhanganesh1 3 года назад +9

    wow! what an energy and a teacher. Thanks for this great teaching.

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

    I was procrastinating while learning Django alot nothing new always happens to me , I was learning by Dj docs tuned this course on I have been studying for like 4-5 hrs now Brian got me hooked mann literally I wish i had a ai bot like brian that explained me everything i needed to know in my life

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

      :0 brian ai...
      Check his ai course 😂

  • @ok.google
    @ok.google 3 года назад +4

    It is such a hard work to squeeze so much information into a short video like this

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

    Wow!
    The pedagogy in this course is brilliant.
    Congrats and thank you!

  • @Nubeloo
    @Nubeloo 4 года назад +28

    We need more teachers like him !

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

    This video is awesome. Clears so many concepts about Django without being overwhelming.

  • @techminipodcasts
    @techminipodcasts 8 месяцев назад +1

    Great delivery of content by one of the best Software Engineers. Looking forward to the next lecture.

  • @Nikita_Code
    @Nikita_Code 9 месяцев назад +3

    1:18:38 where the madness is started 😵‍💫

    • @SaadHussain-op8ps
      @SaadHussain-op8ps 9 месяцев назад

      literally from here the challenging part starts

  • @blackholesun4942
    @blackholesun4942 3 месяца назад +1

    31:28 render(request ,html page,context)
    37:01 newyear app
    43:36 python logic
    48:00 static file
    01:13:13 the info is posted to the same page we are in
    01:34:00 no such table . error

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

    This is the Best django course on the net. I advise anyone searching a good djanho course to focus on this.

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

    Really great lecture. Feel like this video covers so much ground without ever getting too overwhelming.

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

    Sir brine
    You're ture is nice my parents worked as teachers in high school. Your lecturs very marvelous.
    Thank-you
    From
    Kaladhar murakond

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

    Thank you so much for making this wonderful lecture free! I learnt a lot from this course

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

    my university is offering the course in pkr 20000 and he is for free and no words for his teaching thanks a lot sir

  • @freelanceprogrammer9537
    @freelanceprogrammer9537 4 года назад +15

    I suppose the collision error, 1:10:08, was somewhat intentional to explain the next steps in those cases.
    But in this part 54:07 you can look at settings.py tasks is added at the end (after newyear) and at 54:13 urls.py tasks/ is NOT added at the end but before newyear/, hence the error.
    * I put tasks in both cases (settings.py and urls.py) after newyear and there was no error.

  • @Jobwerk
    @Jobwerk 11 месяцев назад +1

    When student is ready teacher will emerge, no need spend lot of money when we have this kind of courses

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

    Open class and no hidden points keeping within paid class.
    Thank you.

  • @abdelrhmanmohammed3593
    @abdelrhmanmohammed3593 4 года назад +7

    This course seems like perfect!

  • @ziad686-c2y
    @ziad686-c2y Год назад

    best web programming course all over the world

  • @malwaredev33
    @malwaredev33 Месяц назад

    Great Lecture and explain simply about Django for beginners.

  • @mamellomolokwane1762
    @mamellomolokwane1762 Месяц назад

    Wow after so long struggling with Django I learned more in this video than when I was trying learn it with AI

  • @o.y.930
    @o.y.930 4 года назад +20

    1:31 was the purest use of incognito I've ever seen.

  • @snowman1185-v
    @snowman1185-v 4 дня назад

    Harvard baby!!! Thanks for the wonderful lessons via the tube of yOu!!

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

    Another great lecture. Thanks for making these available.

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

    at 1:36:17 when Brian changes the add function to, instead of updating the (deleted) global variable, update the task list in the session - why are we using this syntax += [task] ?
    I know that the += is shorthand for append, but why is 'task' , that is obtained from the cleaned_data of the form and is a string, not simply appended to request.session["tasks"]] which is a list via the .append() method?
    If I use request.session["tasks"].append(task) it doesn't work.
    I'm trying to understand why.....
    request.session["tasks"] = a list
    task = a string
    I should be able to use the append method on the list to append the string. I'm clearly missing something here.
    Anyone that can explain this?

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

      Made a stackoverflow question for this because it was bugging me and in the video Brian just 'acts like this is normal syntax' :)
      stackoverflow.com/questions/63449525/append-to-request-sessionslist-in-django/63477092#63477092

    • @georgegabrik1028
      @georgegabrik1028 4 года назад

      Hi, Because i python u cant add one item in list with +=. you must add it to list with append function.

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

      hey, when you use .append() the session by default won't be saved. Documentation here: docs.djangoproject.com/en/2.2/topics/http/sessions/#when-sessions-are-saved
      I'm not sure, but it seems the syntax Brian used gets around that and forces Django to save the session without having to explicitly say: request.session.modified = True.

    • @zerodivided3676
      @zerodivided3676 4 года назад +1

      @@honoriuszbalzak thank you, that was helpful.

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

      @@honoriuszbalzak Thanks

  • @yunaf4609
    @yunaf4609 4 года назад +7

    At 1:36:36 why does he use the += operator instead of using .append()? couldn't he just use .append() again? Was there a reason for this?

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

      hey, when you use .append() the session by default won't be saved. Documentation here: docs.djangoproject.com/en/2.2/topics/http/sessions/#when-sessions-are-saved
      I'm not sure, but it seems the syntax Brian used gets around that and forces Django to save the session without having to explicitly say: request.session.modified = True.

    • @tony9293
      @tony9293 4 года назад +1

      I take it as: CurrentTask + NewTasks = NewTasks(updated)

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

      append(): This does not work request.session["tasks"].append(task)
      but this work
      list_tmp = request.session["tasks"]
      list_tmp.append(task)
      request.session["tasks"] = list_tmp
      : )

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

      @@freelanceprogrammer9537 Thank you!

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

    This is...so much information.

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

    00:11:10 - Routes
    00:28:46 - Templates

  • @МатематикаПрофи
    @МатематикаПрофи 3 года назад +3

    Thank you, bro. I was struggling with getting into Django for like two weeks. You made it easy!

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

    46:07 The smoothest bug fix I have ever seen

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

    i got it very well and i really appreciated and how you guy make it clearly that anybody can understand

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

    This is so powerful. There is nothing else you need to conquer the world (other than some cash runway to keep your experiment alive)

  • @moha.arlaadi
    @moha.arlaadi 2 месяца назад

    brain is brilliant , and I have really enjoyed the lecture, thanks buddy, your are doing great job

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

    1:36:25 why it doesn't work if we utilize append like this??? request.session["tasks"].append(task), it only works if we write request.session["tasks"] += [task]

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

    1:25:28 what determines if a form is valid or invalid? valid according to what criteria? and what is "cleaned_data"? Was that ever explained?

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

    Thanks for the Tutorial. You have clarified some issues with limited time available.

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

    I wish Brian has his own RUclips Channel! He is the best CS professor I have learnt from.

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

      Indeed he has a channel ruclips.net/channel/UCDzVUXiTr3hClI-zzCWbYzg

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

    1:10:14 - mine actually worked and didn't go to 'No' as yours did. Did I just get lucky? Does Django truly randomly decide which .html file to open?

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

      I had the same result and did some experimenting. It is certainly not random.
      Django seems to look in in the 'last url in the project's urlpatterns list' first. (lecture3/urls.py)
      In your lecture3 project 'urls.py', if you change the list as follows:
      urlpatterns = [
      path('admin/', admin.site.urls),
      path('tasks/', include("tasks.urls")),
      path('newyear/', include("newyear.urls")),
      path('hello/', include("hello.urls")),
      ]
      so that 'hello' is last (recall that the hello APP also has a path with a name of 'index').
      If you would now link to url 'index' - django will always go the index url of the hello APP.
      As you can see at 54:10 , Brian (probably on purpose to drive his point home later) puts the path for tasks BEFORE the newyear path in the urlpatterns list.
      You and I added it to the end of the list and as such we did not produce this problem.
      Having said all of that - it is good practice to name your apps so you can explicitly link to them.

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

      @@zerodivided3676 Thank you, you were smart!

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

      @@zerodivided3676 People are so smart at debugging, I hope that I'll be like you someday

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

    cs50 is doing a great job for common people

  • @jorgeav527-xyz
    @jorgeav527-xyz 4 года назад +3

    You fill the gaps I had, such an amazing teacher, now I can read the rest with more confidence, thanks

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

    There's a minimal logical error at the end since the "request.session[tasks]" only creates if the user goes first to the url "/tasks/", however if the user goes first to the url "/tasks/add" , the "request.session[tasks] is not created, so if the user tries to add a new task, it won't work.
    just a little observation, it was a great lecture

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

      its working though

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

      Yes, but add in def add(request):
      if "tasks" not in request.session:
      request.session["tasks"]=[]
      and this work fine! (if the user goes first to the url "/tasks/add")

  • @miho9453
    @miho9453 4 года назад +7

    I finally understood what the csrf token does! That aside, great lecture, thank you!

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

    This is amazing content and very high quality... Love it alot ...Just came for the Django portion.

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

    Thank you as always for the clear succinct lecture!

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

    How can he just do a lecture for nearly 2 hours straight with so much energy. I would fall asleep in the first 5 mins if I was him. Anyway I learnt alot from this lecture

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

    @ 51:00 you need to write {% load static %} above the css link to get it working on the actual version of django.

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

    I usually skip long videos but this thisss was totally worth it. a 1000 blessings to you. also whoever was in charge of the camera movements blew my mind.

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

    Great Lecture Brian Yu!

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

    Dang! This video was made back in January, but they uploaded this two months later.

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

    Thank you from the bottom of my heart Brain. May God bless you 🙏

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

    Thanks to Dr Malan, Jordan Hayashi and Brian Yu i have my own programming channel. Ive started in CS50 earlier than that like 9 years ago

  •  Год назад +1

    estou aplaudindo esse curso com os pés porque com as mãos estou programando

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

    Amazing Presentation. A real pleasure to follow this young and skilled instructor .
    - Thanks

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

    this went from 0 to 100 and Brian says we just scratched the surface of Django

  • @SilveryRedEyes
    @SilveryRedEyes 4 года назад +5

    You're an excellent teacher, thank you!

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

    36:09 - Me watching this tutorial on Christmas day!

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

    19:45 in this page it's show to me attribute error at /app/ .

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

    thank you for the great content. I learned a lot it from you

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

    Great lesson! Thanks for sharing with us :)

  • @kevinzhang-t6f
    @kevinzhang-t6f Год назад

    great tutorial for web dev starters

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

    This guy is just too good

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

    This. Looks. Powerful. Man I need to master it.

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

    1:21:50 but how would you add css to something that was written using Python, even worse how would you add bootstrap to that? I've searched a little and i have only found ugly code, i think that REALLY needed an explanation since raw html is unacceptable

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

      Man this lecture was a freaking trip

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

      You probably should code along him

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

    Really thanks, Harvard.

  • @VinaySharma-sm4dt
    @VinaySharma-sm4dt 4 года назад +1

    Thank you CS50 for this lecture. Great job Brian and David.

  • @GabrielHenrique-qw4yh
    @GabrielHenrique-qw4yh 3 года назад +1

    1:09:00 when i open the tasks page it gives error set object not reversible and if i change {% url 'add' %}
    to [% url 'add' %] the index page opens but clicking the link gives a 404 error. I searched the internet and documentation and don't know what im doing wrong. Can someone help me?

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

    Amazing teacher

  • @durlov5
    @durlov5 4 года назад +1

    This was a cool lesson. Good stuff.

  • @GabrielSiahaan-s7t
    @GabrielSiahaan-s7t Год назад

    What is that mean in 1:13:59 "It doesn't include parameter inside the url the way a get request does, as we saw at Google , for example."

    • @g-whittington
      @g-whittington Год назад

      With get request, if you typed your password in to a submit box, it would show you password in the url and that wouldn’t be good. But like a google search you can see what you typed in the url. Post allows to hide data like passwords

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

    Very nice course, would it be possible to talk about Django Rest Framework please?

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

    Best of the best work

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

    Hello, at 1:08:56 the href="{% url 'add' %}", and href="{% url 'tasks:add' %}", is not working. Has this been changed? Also, href="/tasks/add" works fine.

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

      Was able to fix for 'add', turns out my url patterns for newyear was in {} instead of [].

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

      whoops, turns out I had action="{% url 'tasks:add' %}" method="post" in the bottom form tag lol

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

    I can’t believe this is all for free

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

    Thank you Brian, you are such a great teacher!

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

    Excellent course and good teacher, keep like that. It "1hr" lecture but its really 3hs if you want to follow his peace..Thanks for the Free course.

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

    thank for valuble series

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

    Thanks! Helped a lot.

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

    Thank you for your efforts very helpful video

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

    Oh they actually review your code in this web course :0 now i am anxious 😰😰😰

  • @raghumanvi8489
    @raghumanvi8489 22 дня назад

    If the user at 1st visits the add function without visiting the index function it throws attribute error because tasks key in session dictionary is created in the index function !!

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

    37:07 - Creating a new app (Is it New Year's)

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

    Excelente estructuración del contenido!