CS50W - Lecture 3 - Django

Поділитися
Вставка
  • Опубліковано 11 лис 2024

КОМЕНТАРІ • 382

  • @dudecurioux
    @dudecurioux 3 роки тому +357

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

    • @TerriTerriHotSauce
      @TerriTerriHotSauce 3 роки тому +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 роки тому +40

    really cs50 changed my life

  • @way2ml
    @way2ml 2 роки тому +44

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

  • @abdulwahabkhan1086
    @abdulwahabkhan1086 Рік тому +29

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

  • @staystealth
    @staystealth 2 роки тому +81

    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

  • @sam-nc8zv
    @sam-nc8zv 3 роки тому +83

    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 роки тому +1

      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

  • @innocence3158
    @innocence3158 4 роки тому +103

    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

  • @PelgayJamyang
    @PelgayJamyang 2 місяці тому +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".

  • @bayramalak2673
    @bayramalak2673 4 роки тому +131

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

  • @coreanoquant
    @coreanoquant 3 роки тому +14

    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 роки тому

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

    • @ObaidahNaseer
      @ObaidahNaseer 2 роки тому +3

      The best things in life are free lol

    • @tams805
      @tams805 Рік тому +6

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

  • @cagri5360
    @cagri5360 4 роки тому +41

    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) :)))

  • @xx03_p19
    @xx03_p19 Рік тому +26

    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

  • @malithsenanayakentgl-1052
    @malithsenanayakentgl-1052 3 роки тому +20

    This is the best lecture I have taken on Django

  • @luciouswong1848
    @luciouswong1848 2 роки тому +16

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

  • @Nubeloo
    @Nubeloo 4 роки тому +27

    We need more teachers like him !

  • @SudarshanSharma1
    @SudarshanSharma1 4 роки тому +15

    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 2 роки тому

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

  • @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

  • @naguip91
    @naguip91 4 роки тому +45

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

  • @ok.google
    @ok.google 3 роки тому +4

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

  • @hariombhardwaj038
    @hariombhardwaj038 2 роки тому +2

    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 😂

  • @madhanganesh1
    @madhanganesh1 3 роки тому +9

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

  • @maxpatrickoliviermorin2489
    @maxpatrickoliviermorin2489 Рік тому +1

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

  • @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.

  • @jabraham08
    @jabraham08 2 роки тому +4

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

  • @erickckamanda
    @erickckamanda 7 місяців тому +1

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

  • @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

  • @ziad686-c2y
    @ziad686-c2y Рік тому

    best web programming course all over the world

  • @androidbox6876
    @androidbox6876 Рік тому

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

  • @marketdilemma
    @marketdilemma 9 місяців тому +1

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

  •  2 місяці тому

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

  • @AliRaza_s_Ai
    @AliRaza_s_Ai 3 місяці тому

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

  • @cranleymadeit
    @cranleymadeit 9 місяців тому

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

  • @blackholesun4942
    @blackholesun4942 2 місяці тому +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

  • @vietkhuevu6761
    @vietkhuevu6761 2 роки тому +3

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

  • @codezero1015
    @codezero1015 3 роки тому

    cs50 is doing a great job for common people

  • @abdelrhmanmohammed3593
    @abdelrhmanmohammed3593 4 роки тому +7

    This course seems like perfect!

  • @o.y.930
    @o.y.930 3 роки тому +19

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

  • @cormacbracken2997
    @cormacbracken2997 2 роки тому +2

    Another great lecture. Thanks for making these available.

  • @МатематикаПрофи
    @МатематикаПрофи 3 роки тому +3

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

  • @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

  • @goodthing140
    @goodthing140 Місяць тому

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

  • @DigitalSimba
    @DigitalSimba Рік тому

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

  • @BekBrace
    @BekBrace 7 місяців тому

    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

  • @Nikita_Code
    @Nikita_Code 7 місяців тому +1

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

    • @SaadHussain-op8ps
      @SaadHussain-op8ps 7 місяців тому

      literally from here the challenging part starts

  • @lifelessons5592
    @lifelessons5592 2 роки тому

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

  • @moha.arlaadi
    @moha.arlaadi 21 день тому

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

  • @miho9453
    @miho9453 3 роки тому +7

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

  • @vuanhkhoa9715
    @vuanhkhoa9715 Рік тому

    46:07 The smoothest bug fix I have ever seen

  • @freelanceprogrammer9537
    @freelanceprogrammer9537 4 роки тому +14

    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.

  • @roaringkitty5307
    @roaringkitty5307 3 роки тому +2

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

    • @mergenberdiyev8438
      @mergenberdiyev8438 3 роки тому

      Indeed he has a channel ua-cam.com/channels/DzVUXiTr3hClI-zzCWbYzg.html

  • @ringtonesbyguessapps7737
    @ringtonesbyguessapps7737 4 роки тому +8

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

  • @jdavis2581
    @jdavis2581 3 роки тому +6

    This is...so much information.

  • @VinaySharma-sm4dt
    @VinaySharma-sm4dt 3 роки тому +1

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

  • @jasonsolano2935
    @jasonsolano2935 4 роки тому +12

    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")

  • @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

  • @mathhack8647
    @mathhack8647 3 роки тому +1

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

  • @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.

  • @choooaround
    @choooaround 10 місяців тому

    Thank you as always for the clear succinct lecture!

  • @vincentfernando10
    @vincentfernando10 Рік тому

    This guy is just too good

  • @SilveryRedEyes
    @SilveryRedEyes 4 роки тому +5

    You're an excellent teacher, thank you!

  • @Davidkiania
    @Davidkiania 2 роки тому

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

  • @nura-fq1fz
    @nura-fq1fz 4 місяці тому

    Amazing teacher

  • @kevinzhang-t6f
    @kevinzhang-t6f Рік тому

    great tutorial for web dev starters

  • @javhaasuhochir8126
    @javhaasuhochir8126 2 роки тому

    Really thanks, Harvard.

  • @brunodavis7303
    @brunodavis7303 Рік тому

    Great Lecture Brian Yu!

  • @akshatsharma3081
    @akshatsharma3081 Рік тому +2

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

  • @TSAMikeyo89
    @TSAMikeyo89 3 роки тому +1

    I can’t believe this is all for free

  • @darkooo94
    @darkooo94 Рік тому

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

  • @mon0theist_tv
    @mon0theist_tv 11 місяців тому +1

    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?

  • @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

  • @usmanbajwa9179
    @usmanbajwa9179 Рік тому

    Best of the best work

  • @friskomayufid
    @friskomayufid 3 роки тому +1

    Thank you Brian, you are such a great teacher!

  • @blabla-kk8bl
    @blabla-kk8bl 3 роки тому +2

    million times better than udemy crabs.

  • @Thedailymeta
    @Thedailymeta Рік тому

    Simply Amazing.

  • @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.

  • @financialprogrammer
    @financialprogrammer Рік тому

    thank for valuble series

  • @doriansmith5667
    @doriansmith5667 8 місяців тому

    God bless you.

  • @mirshodoripov1035
    @mirshodoripov1035 2 роки тому +1

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

  • @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!

  • @marioecn
    @marioecn 2 роки тому +1

    Great lesson! Thanks for sharing with us :)

  • @divyanshkhetan
    @divyanshkhetan 2 роки тому +1

    Thanks! Helped a lot.

  • @ivankljun2542
    @ivankljun2542 4 роки тому +1

    Great explanation, thank you Brian and David!

  • @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.

  • @pfever
    @pfever 2 роки тому +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]

  • @rodrigoponcecortes5193
    @rodrigoponcecortes5193 2 роки тому +1

    How do you add CSS to the html template? I can't seem to be able to add it

  • @juniorfranke
    @juniorfranke Рік тому

    Brian & david u are my heart Beat=true:

  • @imanfarkhadaf5296
    @imanfarkhadaf5296 10 місяців тому

    Thank you a million

  • @durlov5
    @durlov5 4 роки тому +1

    This was a cool lesson. Good stuff.

  • @lifelessons5592
    @lifelessons5592 2 роки тому

    Thank you for your efforts very helpful video

  • @sayori3939
    @sayori3939 2 роки тому +1

    But what if you have a layout that's common across all your applications, where do you put it?

  • @pavankalyanadusumalli8827
    @pavankalyanadusumalli8827 4 роки тому +5

    How can we add CSS (styling based on id or class) to the HTML input fields generated by django

    • @hamerhaai6274
      @hamerhaai6274 4 роки тому +1

      Good question. I found this: tutorial.djangogirls.org/en/css/

    • @KarimCTF
      @KarimCTF 4 роки тому

      By adding a static files in settings.py

    • @abhishekrawat8579
      @abhishekrawat8579 4 роки тому +1

      the best way is to use dev tools in your browser and check the input fields and then grab predefined attributes.
      this works for me......very well.....
      but if you want use django thing use django widgets to set attributes first then use them in your css

  • @ibrahimabarry8839
    @ibrahimabarry8839 4 роки тому +2

    merci beaucoup tu es le meilleur

  • @cringecrimson94
    @cringecrimson94 3 роки тому +7

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

  • @sayori3939
    @sayori3939 2 роки тому

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

  • @sagargaigawale
    @sagargaigawale 4 роки тому +3

    I'm completely lost, couldn't follow along the Django installation and all the commands. I'm using Windows and wish to set up VS Code to use the terminal but i haven't found any useful docs / tutorial regarding the set up. Can anyone help?

    • @forgotten-1
      @forgotten-1 4 роки тому

      On youtube I followed a tutorial from a guy named Tubemint for a python and django setup on windows. From there I installed vscode, and once I had python and django running I created my project and went to the cmd window and typed code . (remember there is a space and a period after code) which automatically opened my project on vs code. You can even open up the project folder on vs code and it will show every file for the project that way as well.

    • @otmaneallaoui1750
      @otmaneallaoui1750 4 роки тому

      here is an exemple can help you
      code.visualstudio.com/docs/python/tutorial-django

    • @bvedantcodes
      @bvedantcodes 4 роки тому +2

      If you're on Windows I would highly recommend installing a bash environment program like Git Bash (included in Git for Windows) or Windows Subsystem for Linux. The commands that Brian uses in his zsh shell can be done verbatim in your bash shell.

    • @FrederickFIintstone
      @FrederickFIintstone 3 роки тому

      @@bvedantcodes That will create a nightmare of PATH issues for noobs just starting out.

  • @fernandovasquez1032
    @fernandovasquez1032 2 роки тому +2

    When I run the python manage.py runserver the second time after we create the app hello it shows a error. Please HELP

    • @Hackers-wrld
      @Hackers-wrld 2 роки тому

      make sure the hello app is added in the settings.py

    • @soliakt
      @soliakt 2 роки тому

      copy paste my code in views.py and it will work:
      from http.client import HTTPResponse
      from django.http import HttpResponse
      from django.shortcuts import render
      # Create your views here.
      def index(request):
      return HttpResponse("Hello, world!")

  • @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 Рік тому

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