[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Django Tutorial for Beginners – 12 – Writing Another View
by
Tags:
Comments
38 responses to “Django Tutorial for Beginners – 12 – Writing Another View”
-
you saved my thinging
-
Sir for latest version what we write if I write
Path (' ')
Same as use said than I get error pls tell how to slove -
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'), -
What's the point of putting 'P' in regex? Shouldn't (?<album_id>….) work fine?
-
django 2.0.5
path('<str:Album_id>', views.detail, name = 'detail'), -
Django tutorial 12 Writing Another View
apps used in this tutorialmusicurls .py
musicviews .py -
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
-
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') -
url(r'^(?P<album_id>[0-9]+)/$', views.html, name='detail') just isn't working. I wish this bit of the video was clearer.
-
alright hostels?
-
The url () function is depreciated, for people importing path . Do use path('<album_id>'',views.detail, name = ''detail'), instead..
-
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 -
in django 2.0 coding little different.
i used : path('<int:album_id>', views.detail, name='detail'), in urls.py -
in django 2.0 you just need to add pretty url like
path('<int:album_id>', views.detail),
and it will work -
Can anyone show this using path() instead of url?
-
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').
-
Sorry guys already saw where the problem is; it was on the view section
-
We can replace [0-9]+ with d+ the last one the proper regular expressions.
-
My url doesn't work, it downloads instead of showing the text in the views section
what might be the issue? -
I like how you say grou p
-
i couldn't use str()
-
1:01 "… and when we cler .. clok clo clk .. click!", you're funny Bucky
-
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.
-
One question bucky, what is that accent, sounds american but then you say "mate" a lot, "websoit"? @thenewboston
-
Great vids hoss!
-
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') -
For the second view, it got a TypeError. Could anyone help me please??
-
up until now, these guide has been so simple yet details.
Really appreciated all these videos you made 😀 -
that question mark and p look so weird
-
can anyone explain that regular expression
-
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.
-
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 syntaxCan someone help me?
-
i'm just copying and paste all url an views but not able to make a new one which i want /////
-
actually and i think its more robust to just use "d+" instead of having "[0-9]+"
-
Your courses are outstanding. Are you on IRC or Ricochet IM?
-
How do I do the same thing but instead of album_id I put the album_title ?
-
For those who might get a 404 error, check your url.py in the main app.
It should be like thisurl(r'^music/', include('music.urls'),)
NOT like this: url(r'^music', include('music.urls'),)
-
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