Django Tutorial for Beginners – 12 – Writing Another View

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

38 responses to “Django Tutorial for Beginners – 12 – Writing Another View”

  1. shankar bhandari Avatar

    you saved my thinging

  2. Techno sf Avatar

    Sir for latest version what we write if I write
    Path (' ')
    Same as use said than I get error pls tell how to slove

  3. shadeen Rajib Avatar

    django 2.0 you just need to add pretty url like …..
    def detail(request, album_id):
    return HttpResponse("<h2>Detail for Album ID: %s. " % album_id)
    path('<int:album_id>', views.detail, name='detail'),

  4. Ameya Datar Avatar

    What's the point of putting 'P' in regex? Shouldn't (?<album_id>….) work fine?

  5. makhlouf idir nassim Avatar

    django 2.0.5
    path('<str:Album_id>', views.detail, name = 'detail'),

  6. roger smith Avatar

    Django tutorial 12 Writing Another View
    apps used in this tutorial

    musicurls .py
    musicviews .py

  7. Phạm Quang Tuấn Avatar

    I got an error. that's no "Details for Album is… bla bla" shown, but it shown " This is the Music app homepage" like the previous lession! any help everyone! tks all

  8. Eric Pfeiffer Avatar

    In Django 2.0 you can use:
    from django.urls import re_path
    re_path(r'^(?P<album_id>[0-9]+)/$', views.detail, name='detail')

  9. Matt Whitby Avatar

    url(r'^(?P<album_id>[0-9]+)/$', views.html, name='detail') just isn't working. I wish this bit of the video was clearer.

  10. peyman kheiri Avatar

    alright hostels?

  11. Suman Astani Avatar

    The url () function is depreciated, for people importing path . Do use path('<album_id>'',views.detail, name = ''detail'), instead..

  12. vert53 Avatar

    Explanation of the regex:
    Groups in regex are normally referred to by a number. the syntax used above in the url allows the capturing group to be referred to using the given name instead of a number. (?P<name>…)
    Django 2.0 stopped using this syntax anyway though

  13. alfian candra Avatar

    in django 2.0 coding little different.
    i used : path('<int:album_id>', views.detail, name='detail'), in urls.py

  14. mohammed salah Avatar

    in django 2.0 you just need to add pretty url like
    path('<int:album_id>', views.detail),
    and it will work

  15. karan dave Avatar

    Can anyone show this using path() instead of url?

  16. Rajat Sengupta Avatar

    url(r'^(?P<album_id>[0-9]+)/$', views.html, name='detail').The above url mapping will work with an additional backlash to excape the front slash here as url(r'^(?P<album_id>[0-9]+)/$', view.detail, name='detail').

  17. Krafty Coder Avatar

    Sorry guys already saw where the problem is; it was on the view section

  18. Mohamed Ayman Avatar

    We can replace [0-9]+ with d+ the last one the proper regular expressions.

  19. Krafty Coder Avatar

    My url doesn't work, it downloads instead of showing the text in the views section
    what might be the issue?

  20. Kris Avatar

    I like how you say grou p

  21. Life Sucks Avatar

    i couldn't use str()

  22. Khánh Lê Avatar

    1:01 "… and when we cler .. clok clo clk .. click!", you're funny Bucky

  23. Raniel Doberto Avatar

    Any idea why im getting this?

    Using the URLconf defined in website.urls, Django tried these URL patterns, in this order:

    ^admin/
    ^music/ ^$ [name='index']
    ^music/ ^/(?P<album_id>[0-9]+)/$ [name='detail']

    The current path, music/1/, didn't match any of these.

  24. Fahim Zapoh Avatar

    One question bucky, what is that accent, sounds american but then you say "mate" a lot, "websoit"? @thenewboston

  25. Ethan Axline Avatar

    Great vids hoss!

  26. sandeep chauhan Avatar

    if u are using url(r'^music' , include('music.urls'))
    then use
    url(r'^/(?P<album_id>[0-9]+)/$',views.detail, name='detail')
    instead of
    url(r'^(?P<album_id>[0-9]+)/$',views.detail, name='detail')

  27. Jason Song Avatar

    For the second view, it got a TypeError. Could anyone help me please??

  28. Jin Nii Sama Avatar

    up until now, these guide has been so simple yet details.
    Really appreciated all these videos you made 😀

  29. Lucas C Avatar

    that question mark and p look so weird

  30. Akula Dheeraj Avatar

    can anyone explain that regular expression

  31. 1strog Avatar

    ok, let's say you have articles that are posted on a certain date. And you would to use that in your url like: day/month/year/article_id, how would that look as a url regex? And how would that look in an href of the Django templating language? All I have is the article which has the publication date, and it's id.

  32. PythonMan Avatar

    Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03ADDE88>
    Traceback (most recent call last):

    File "C:UsersMeDesktopwebsitemusicurls.py", line 9
    url(r'^music/(?P<album_id>[0-9]+)/$', views.detail, name='detail')
    ^
    SyntaxError: invalid syntax

    Can someone help me?

  33. Himanshu Pharawal Avatar

    i'm just copying and paste all url an views but not able to make a new one which i want /////

  34. Jarvis Millan Avatar

    actually and i think its more robust to just use "d+" instead of having "[0-9]+"

  35. Jack Britton Avatar

    Your courses are outstanding. Are you on IRC or Ricochet IM?

  36. Neydson Macedo Avatar

    How do I do the same thing but instead of album_id I put the album_title ?

  37. procast Avatar

    For those who might get a 404 error, check your url.py in the main app.
    It should be like this

    url(r'^music/', include('music.urls'),)

    NOT like this: url(r'^music', include('music.urls'),)

  38. Florian Avatar

    The Variable album_id within in views.py file: I just dont see, why python knows, that the variable exists? We did not import anything from urls, right?

Leave a Reply

Your email address will not be published. Required fields are marked *