Django Tutorial #3 - URLs and Views

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 พ.ย. 2017
  • DONATE :) - www.paypal.me/thenetninja
    Hey all, in this django tutorial for beginners we'll take a look at the urls.py and the views.py files. Both of these files work in tandem to decipher a URL request made by a browser and to react to it to send a response.
    ----- COURSE LINKS:
    + Python tutorials - goo.gl/xD2AvX
    + Course files - github.com/iamshaunjp/django-...
    + Django docs - docs.djangoproject.com/en/1.11/
    + Atom editor - atom.io/a
    + CMDER - cmder.net/
    ======== Other Tutorials =========
    ----- NODE.JS TUTORIALS
    • Node JS Tutorial for B...
    ----- MONGODB TUTORIALS
    • MongoDB Tutorial for B...
    ----- SUBSCRIBE TO CHANNEL - / @netninja
    ======== Social Links ==========
    Twitter - @TheNetNinja - / thenetninjauk
    Patreon - / thenetninja

ความคิดเห็น • 163

  • @MegaDonaldification
    @MegaDonaldification 10 หลายเดือนก่อน +2

    Thank you very much. The diagram was the super star which helped the word in my mind to find peace with the concept. Now, you have cut my work down to where I can continue from.

  • @kbprojekty
    @kbprojekty 4 ปีที่แล้ว +17

    What makes your videos great is that you first explain the top-down view of the whole thing and then get to details. To be able to easily understand something, I first need to understand what it is and why am I doing it. How something works before details and procedures. You're doing this very well, thanks for your videos, you made my learning day a lot easier! ;)

    • @jonyfrany1319
      @jonyfrany1319 2 หลายเดือนก่อน

      That’s the best way to teach

  • @temprmj1
    @temprmj1 6 ปีที่แล้ว +68

    Excellent teaching style, not too fast and not dumbed-down either

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +5

      Thanks so much :). Glad you like.

    • @alanmoreno6330
      @alanmoreno6330 2 ปีที่แล้ว +1

      @@NetNinja ohh yeahh i likeyy

    • @mixfruit000
      @mixfruit000 2 ปีที่แล้ว +1

      teaching style is best best best...................................

  • @TaHrPa
    @TaHrPa 2 ปีที่แล้ว +9

    I'm enrolled in an academy for software development, they have web development with django course and I also watch a lot of youtube and udemy videos. I've been learning django for a few weeks and I have to say your videos are far superior to everything I've seen so far.

    • @maxconstable2535
      @maxconstable2535 2 ปีที่แล้ว +2

      I was just about to type the same. Everything I found on the courses seemed almost impersonal and just "this is what you do", rather than why. These videos are 100x better and I'm so glad they're here

    • @mrgrade3_
      @mrgrade3_ ปีที่แล้ว +1

      Same here brother

  • @pythonwithpower5664
    @pythonwithpower5664 3 ปีที่แล้ว +3

    This course was recommended to me by someone and I couldn't be happier, definitely going to finish the entire tutorial. Thanks, you're great!

  • @tunasalad3919
    @tunasalad3919 6 ปีที่แล้ว +2

    you're literally saving somebody's day by doing this. Kudos...I wish everybody should have taught me like this.

  • @vinayakad3796
    @vinayakad3796 2 ปีที่แล้ว +1

    Will definitely recommend this to anyone who doesn't understand Django!!! This playlist is a gem

  • @user-ph2bc8kc6c
    @user-ph2bc8kc6c 4 ปีที่แล้ว +1

    Amazing tutorial! especially thanks to covering every little step as explain the "from . import views" which explain that "." means a reference to the working directory. Also the names' convention is beautifully done. Thank you!

  • @ianpan0102
    @ianpan0102 4 ปีที่แล้ว +1

    Love the diagram you showed at the beginning, I'm going to use this too tomorrow in my class!

  • @piotrz6872
    @piotrz6872 3 ปีที่แล้ว

    You really know how to walk people through by the hand.
    Thank you for prepering this course.

  • @Peekaymaja
    @Peekaymaja 6 ปีที่แล้ว

    Best series ever. I thought django is difficult. I'm excited to learn more. Thank you very much man keep up the good job

  • @MB-qk1bj
    @MB-qk1bj 4 ปีที่แล้ว +1

    Thank you very much for this wonderful tutorial, i was so lost now everything makes perfect sense thank you so much

  • @rahulparmar208
    @rahulparmar208 5 ปีที่แล้ว

    This process i hv been trying to learn for last 1 week.. Finally thanks tobu bro.. I got thr zest of it now.... Superb

  • @taihatranduc8613
    @taihatranduc8613 4 ปีที่แล้ว +1

    wow. you make it so much easy to understand. you're completely different from all TH-camr i know. what a great teacher!

    • @NetNinja
      @NetNinja  4 ปีที่แล้ว

      Thanks so much 😊

  • @paulthompson3156
    @paulthompson3156 3 ปีที่แล้ว

    Well explained. Thank you ! It was great the way you explained WHY you are doing something. Not just HOW to do something.

  • @Boopadoopap
    @Boopadoopap 6 ปีที่แล้ว +5

    This has been the best, most clear tutorial on django I've seen yet. Thanks a ton!

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว

      Thanks :)

  • @birdstheword5
    @birdstheword5 5 ปีที่แล้ว

    thanks so much for explaining what you are doing while you are doing it, nothing was making sense until I found this tutorial :)

  • @ankushchavhan1332
    @ankushchavhan1332 ปีที่แล้ว +1

    Hey man you are giving such valuable material for free 🙂.
    You dropped your 👑

  • @jerrymardeburg9313
    @jerrymardeburg9313 ปีที่แล้ว

    You are the best tutor I have seen so far
    The way you breakdown everything to basis is amazing. Much Love

    • @NetNinja
      @NetNinja  ปีที่แล้ว

      I appreciate that! Thanks jerry :)

  • @WorldUpdates4U
    @WorldUpdates4U 4 ปีที่แล้ว

    Sir you are brilliant by watching your videos I built confidence and now I am capable enough that I can clear out my interview.

  • @aghiadalzein3069
    @aghiadalzein3069 4 ปีที่แล้ว

    The most clear explanation ,thanks a lot.

  • @akakop
    @akakop 4 ปีที่แล้ว

    This is one of the best tutorials on django

  • @neosinan1
    @neosinan1 3 ปีที่แล้ว

    Last night I read official django page and stackoverflow for 3 hours and I couldnt solve my problems. I took 2 minute and 27 second of this video was enough. Thanks.

  • @dirtymopwater2868
    @dirtymopwater2868 5 ปีที่แล้ว

    This was very clearly explained. Thank you

  • @virtualgirl7697
    @virtualgirl7697 4 ปีที่แล้ว

    Excellent explaination..so much simplified

  • @beresfordsylvah8874
    @beresfordsylvah8874 2 ปีที่แล้ว

    Am greatful, you made me understand this views and urls syntax in just minutes.👏

  • @etiennelauzier5698
    @etiennelauzier5698 6 ปีที่แล้ว

    You rock !!!!!! Excellent job my friend!!!
    May science bless you.

  • @AshishSharma-pm1dc
    @AshishSharma-pm1dc 5 ปีที่แล้ว +2

    Bro you have explained this in such a good manner.Subscribed😁

    • @NetNinja
      @NetNinja  5 ปีที่แล้ว

      Thanks man, glad you liked :)

  • @adityadwivedi4405
    @adityadwivedi4405 4 ปีที่แล้ว

    Nice tutorials dude. No bs directly to point 👍

  • @lancemkhokhelidube6076
    @lancemkhokhelidube6076 3 ปีที่แล้ว

    DUUUUUUUUDE i literally understand and follow everything you are teaching...I've watched a few other Django tutorials but was never able to make a simple page...today I MADE FREAKIN 20 pages

    • @NetNinja
      @NetNinja  3 ปีที่แล้ว

      Thanks so much and that's awesome! 😃

  • @evgryz
    @evgryz ปีที่แล้ว

    Hi man, greetings from Russia. Just wanted to tell you explained all this stuff much better than any Russian textbook that is always written in soviet-thus-impossible-to-understand style even though it's 21st century already. THANK YOU for your django tutorials!

  • @seth4402
    @seth4402 6 ปีที่แล้ว +5

    This is great stuff. Any chance you'll be updating the tutorial to version 2 of Django? I think the new version uses path() instead of url(), at least according to the documentation tutorial.

  • @miguelnuno928
    @miguelnuno928 4 ปีที่แล้ว

    You help me a lot. Thank you for share your knowledge

  • @bastonalexandru
    @bastonalexandru 5 ปีที่แล้ว

    Great tutorial m8, you helped me a lot! Thank you :D

  • @Anom21
    @Anom21 3 ปีที่แล้ว

    Hey man, it was a big help, can't thank you enough

  • @unicorn-space1934
    @unicorn-space1934 4 ปีที่แล้ว

    Thank you..it's help me to my project ..once again thank you

  • @yusufrumi1626
    @yusufrumi1626 4 ปีที่แล้ว

    Thanks so much. Very well explained.

  • @Timbo101001
    @Timbo101001 6 ปีที่แล้ว +2

    This made me understand what I've been trying to understand for ages. Hero.

  • @TheBurningofSolomon
    @TheBurningofSolomon 5 ปีที่แล้ว

    Incredible tutorials, friend. Subscribed mate

  • @anroiduser1222
    @anroiduser1222 3 ปีที่แล้ว

    I have learned a lot and feel cool, you are good mate!

  • @sostomc
    @sostomc 5 ปีที่แล้ว

    This is really good! thanks.

  • @sandunnirmala9269
    @sandunnirmala9269 6 ปีที่แล้ว +3

    i am getting this error in cmd. How to solve this sir
    AttributeError: module 'myweb.views' has no attribute 'homepage'

  • @mindpower421
    @mindpower421 5 ปีที่แล้ว

    amazing video, one of the best video on this planet

  • @user-zp5oq6sg9p
    @user-zp5oq6sg9p 6 ปีที่แล้ว +1

    к сожалению я английским языком не владею, но просто глядя на схемы, я понял принцип работы Django. Большое спасибо.

  • @jetspray3
    @jetspray3 4 ปีที่แล้ว

    even though i understand function views, however that was the best explanation every from all the other videos on youtube. I hope you have a video with generic views.

  • @baseh6272
    @baseh6272 4 ปีที่แล้ว

    Awesome teaching style

  • @nhanLe_
    @nhanLe_ 2 ปีที่แล้ว

    Excellent, keep up the good work

  • @sjsks2
    @sjsks2 4 ปีที่แล้ว

    such a great work !!

  • @haritpatel5001
    @haritpatel5001 2 ปีที่แล้ว

    You are awesome Shawn love form India.

  • @asiimwemuhabuzimuhoozi3422
    @asiimwemuhabuzimuhoozi3422 3 ปีที่แล้ว

    Thanks for the help

  • @user-cc8kb
    @user-cc8kb 3 ปีที่แล้ว

    Amazing. Thank you very much! :)

  • @jisgerald8723
    @jisgerald8723 3 ปีที่แล้ว

    Although this video dates back, thanks a bunch!!!👍🏽

    • @ifiokekott2684
      @ifiokekott2684 3 ปีที่แล้ว

      Abi, I'm wondering what version of Django is that?

  • @michaelkamau9565
    @michaelkamau9565 5 ปีที่แล้ว

    Thank you so much!!

  • @sangharshadhital6017
    @sangharshadhital6017 5 ปีที่แล้ว +1

    path(r'^$',home) does not work on my pycharm? it works without using r'^$' symbol... why is it so?

  • @andyrobertson9473
    @andyrobertson9473 4 ปีที่แล้ว

    Thanks so much

  • @yassir3715
    @yassir3715 6 ปีที่แล้ว

    in django 2.0.7 when I use regular expressions to setup URLs that ends up with django responding with an Error instead of the specified response in the views.py file, so we don't use regex any more?

  • @StoneZhong
    @StoneZhong 5 ปีที่แล้ว +1

    this demo is about django 1.x, the most recent django version is 2.1.7 as of today, I think people uses something like "urlpatterns = [
    path('', views.index, name='index'),
    ]" for django 2.x

  • @happy_cutman
    @happy_cutman 4 ปีที่แล้ว

    Thanks for video! What kind of font you use in Atom?

  • @lukslda1
    @lukslda1 5 ปีที่แล้ว

    Thanks you! Take your like! 👍🏼

  • @javierlizarazu7680
    @javierlizarazu7680 5 ปีที่แล้ว

    what version of django are you using? can i follow the tutorial with django 2.0.7 installed?

  • @swatir.567
    @swatir.567 4 ปีที่แล้ว

    THANK YOU OMGGGGGG THQNK YOU SOOO MUCHHH

  • @erdemsenturk3889
    @erdemsenturk3889 6 ปีที่แล้ว +11

    love you

  • @VadimBesedin
    @VadimBesedin 5 ปีที่แล้ว +7

    In newer version of Django, in views.py, instead of:
    return HttpResponse('about')
    use:
    return render(request,'about.html')

    • @studiozandra8714
      @studiozandra8714 5 ปีที่แล้ว

      thank you, Vadim!

    • @adityadwivedi4405
      @adityadwivedi4405 4 ปีที่แล้ว +4

      You also need to include
      frome django.shortcuts import render

  • @yashv2000
    @yashv2000 3 ปีที่แล้ว

    Best series, ngl

  • @gilfalkovitch9669
    @gilfalkovitch9669 5 ปีที่แล้ว

    There's something weird...
    If the "about" function requires a "request" parameter, how come it does not error out as you call it WITHOUT passing one?

  • @arturofm
    @arturofm 5 ปีที่แล้ว

    Ninja I love your tuto, but this one is kind of outdated now with Django 2, and the path vs url, are you planning to update it?
    Thanks for the good work

  • @johnrogers3315
    @johnrogers3315 4 ปีที่แล้ว

    excellent explanations, thank you. Is there any intention of updating this series to Django 3? Would happily pay for that. Thanks again

  • @ifargantech
    @ifargantech 3 ปีที่แล้ว

    Now being on home I can access the login path... but after being on the login path I can't access the home path... It says 127.0.0.1:8000/login/home doesn't exist. How I can leave the login ?

  • @prettycode4028
    @prettycode4028 4 ปีที่แล้ว

    wow, thenkz bro.

  • @OliverCao
    @OliverCao 3 ปีที่แล้ว

    you are a real G

  • @nightingalenath943
    @nightingalenath943 5 ปีที่แล้ว

    Please the creating the project am not able to get the;
    from django.conf.urls import urls, but rather
    from django.urls import path. So am not able to follow you on this tutorial.
    Please help me and i will be grateful. Thanks

  • @rameshmathad
    @rameshmathad 6 ปีที่แล้ว

    the runserver gives NameError: name 'path' is not defined along with 100 other lines of errors waht to do please help
    ..../?

  • @user-mfsc-2024
    @user-mfsc-2024 6 ปีที่แล้ว

    without using regx, is url('admin/', admin.site.urls) working?

  • @peymannaji
    @peymannaji 6 ปีที่แล้ว

    Why do we need request parameter for the functions in the views.py ?

  • @increadibleangel7980
    @increadibleangel7980 3 ปีที่แล้ว

    Does any changes for 2020 version? Or it wil work

  • @SMA5HPL
    @SMA5HPL 6 ปีที่แล้ว +2

    are you going to make Flask tutorials ? :V

  • @rahulparmar208
    @rahulparmar208 5 ปีที่แล้ว

    Can u please for a fresher what shud i know before applying for interviews for bavend python developer job

  • @joyaljoseph7781
    @joyaljoseph7781 4 ปีที่แล้ว

    What do settings.py and manage.py do?
    Can I get the full code of those files?

  • @dhruvpendharkar488
    @dhruvpendharkar488 4 ปีที่แล้ว

    Why is request not a required paramater n Http Response method . For example it is a parameter in render method for templates.

  • @aliaksandrhn1
    @aliaksandrhn1 2 ปีที่แล้ว

    I just love how the British pronounce the letter "H". Epic.

  • @hardeeraval5770
    @hardeeraval5770 3 ปีที่แล้ว +1

    Page not found (404) Request Method: GET Request URL: bnyrj.pythonanywhere.com/ Using the URLconf defined in mysite. urls, Django tried these URL patterns, in this order: polls/ admin/ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file.
    i m getting this error pls give me solution

  • @atirrasheedhashmi
    @atirrasheedhashmi 2 ปีที่แล้ว

    9:30 "request" is not accessed by pylance Why & it's not updating the page after running python manage.py runserver in cmd
    Help me :(

  • @mohammedyahya8411
    @mohammedyahya8411 4 ปีที่แล้ว

    thank you :)

  • @ImtoolVideos
    @ImtoolVideos 6 ปีที่แล้ว +2

    My understanding is that in about a week or two regex will no longer need to be used -with the new release dropping in December

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +3

      You're absolutely correct :). In django 2 url params will be much easier to use.

    • @kewang08
      @kewang08 6 ปีที่แล้ว

      can you redirect me to understand the url params? which is path. quite confusing now

  • @damniexist51
    @damniexist51 6 ปีที่แล้ว +1

    its
    urlpatterns = [
    path('admin/', admin.site.urls),
    ]
    for me
    whats the difference?

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +2

      Hey, path is the Django 2 version. The only difference using path instead of URL is that you don't need RegEx for the url structure :)

    • @damniexist51
      @damniexist51 6 ปีที่แล้ว

      thanks

    • @damniexist51
      @damniexist51 6 ปีที่แล้ว

      :)

  • @Lbmaniak
    @Lbmaniak 5 ปีที่แล้ว

    nice thx

  • @superduper911
    @superduper911 2 ปีที่แล้ว

    thanks ..

  • @m.jsoltani8133
    @m.jsoltani8133 4 ปีที่แล้ว

    what about venv ?? virtual environment is not necessary in Django?

  • @collinsadhola8278
    @collinsadhola8278 3 ปีที่แล้ว

    Awesome!

    • @NetNinja
      @NetNinja  3 ปีที่แล้ว

      Thank you! :)

  • @definty
    @definty 4 ปีที่แล้ว

    Isn't the 'r' to show its a regular expression, what's a raw string?

  • @raymondmichael4987
    @raymondmichael4987 5 ปีที่แล้ว

    Hello Ninja master, will this wagon receive rewriting (as react wagon) to reflect django version 2.x, as few things have changed..
    If not we'll have jump on the docs, I guess
    Just asking,

    • @NetNinja
      @NetNinja  5 ปีที่แล้ว

      Hey, yeah, at some point I'll be doing a re-run of the whole series using Django 2.x - whatever is current at the time. I've got a few other playlists to do first though!

    • @raymondmichael4987
      @raymondmichael4987 5 ปีที่แล้ว +1

      @@NetNinja, I can live with it.

  • @joebegleycodes1347
    @joebegleycodes1347 5 ปีที่แล้ว +1

    The regex portion for the URLs didn't work for me.
    To fix the issue use re_path instead of path.
    First, put this up top "from django.urls import re_path"
    Then, use "re_path" instead of "path"

    • @JojYTHandle
      @JojYTHandle 5 ปีที่แล้ว

      Thanks for posting this, I was confused

    • @joebegleycodes1347
      @joebegleycodes1347 5 ปีที่แล้ว +1

      url instead will also work. He changed it between the videos.

  • @ravabat5841
    @ravabat5841 4 ปีที่แล้ว

    Hello, what the different between HttpResponse and render function? Thank you

    • @syntaxis5584
      @syntaxis5584 4 ปีที่แล้ว

      render is a wrapper function that uses HttpResponse to render a view

  • @pthiago_s5075
    @pthiago_s5075 4 ปีที่แล้ว +1

    Damn this video made me wish to get up from the bed and get back to vs code

  • @hassanalattas8870
    @hassanalattas8870 6 ปีที่แล้ว

    Can i do PWA by Django

  • @user-xn4yu5rn9q
    @user-xn4yu5rn9q 4 ปีที่แล้ว

    Good

  • @nabilanaz4830
    @nabilanaz4830 4 ปีที่แล้ว

    url(r'^$',views.homepage),
    url(r'^$',views.about),
    When I run the above,the content of view.homepage gets displayed. Why doesn't the content of views.about gets displayed instead?Since that line of code got executed in the end?

    • @syntaxis5584
      @syntaxis5584 4 ปีที่แล้ว

      I know this is old but with Django it will display the first view it finds that matches the URL

    • @syntaxis5584
      @syntaxis5584 4 ปีที่แล้ว

      I should add this video is out of date and using Django 1.11. Django is currently in version 3.0 3.0 doesn't use regex so simply path("", ,views.homepage) is the way to do it

  • @devanshsolani2593
    @devanshsolani2593 4 ปีที่แล้ว +1

    Error I am getting is, when in cmd I type "python manage.py runserver", It does not start the server.

    • @somethingtosay3
      @somethingtosay3 4 ปีที่แล้ว +1

      make sure you cd in the src of the Dev folder and type source bin/activate and then type the runserver again

    • @ravabat5841
      @ravabat5841 4 ปีที่แล้ว

      @@somethingtosay3 yep, it's true

    • @maryuma881
      @maryuma881 3 ปีที่แล้ว

      You should try install python properly by using Windows Store, and add django scripts into PATH

  • @prasadkadu9737
    @prasadkadu9737 3 ปีที่แล้ว

    some parts have updated in django you might consider updating your videos least about Urls.py

  • @Samuel-br8wc
    @Samuel-br8wc 6 ปีที่แล้ว

    what version are you using django in this playlist?

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +3

      Hey, it's version 1.11, the one directly before 2 was released. Everything in this series should still work with Django 2. But Django 2 has added a couple of nice features such as using paths instead of urls - meaning we don't need those nasty RegEx anymore :)

    • @Samuel-br8wc
      @Samuel-br8wc 6 ปีที่แล้ว

      thank you for create awsome django tutorial. I understand with the difference URLs.