[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Django Tutorial for Beginners – 21 – Namespace and HTTP 404 Shortcut
by
Tags:
Comments
30 responses to “Django Tutorial for Beginners – 21 – Namespace and HTTP 404 Shortcut”
-
How can we pass a string or an error message with get_object_or_404() function? If we can't , then using try-except might be better .
-
Django tutorial 21 Namespace and HTTP 404 Shortcut
apps used in this tutorialmusictemplatesmusicindex.html
musicurls .py
musicviews .py -
6
-
Edit the main urls.py file and add namespace attribute like this :
url(r'^music/', include('music.urls', namespace="music")),
otherwise application won't work
-
Thanks Bucky!
-
I am getting only the image in details page after putting this on the detail function in view.py
from django.shortcuts import render, get_list_or_404
def detail(request, album_id):
album = get_list_or_404(Album, pk=album_id)
return render(request, "music/detail.html", {"album": album}) -
I am getting blank details page after putting this on the detail def
album = get_list_or_404(Album, pk=album_id)
return render(request, "music/detail.html", {"album": album}) -
Wow, it makes a whole lot more sense now why you make a url file in each app. Thanks Bucky!
-
since the index.html belongs to music app then shouldn't the link to details seek out for the music app's details without even mentioning the namespace?? But if so happens then the need for namespace shouldn't arise.
-
great..
-
do you have any rails tutorial?
-
I followed the tutorial and get the error that Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'music/(?P<album_id>[0-9]+)/$']. Does anyone know how to fix that?
-
Your Tutorials are very clear and anyone can learn Python. Thank you very much. Good for new gen.
-
dude,I need you source codes from where can i get them?
can't find this tutorial's on GitHub -
dude you are AWESOME, the best videos ever ! thanks!
-
<li><a href = "{% url 'music:detail' album_id %}">{{album.album_title}}</a></li>
the error is in this line -
i just followed the tutorial but after executing the code i got below error.
Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'music/(?P<album_id>[0-9]+)/$'] -
I'm using Django 1.10 and I am having a hard time with static_root as it seems to be pointing to Viberr/website/static. It should be Viberr/music/static. I cannot get style.css to work as it gives a 404. I have been going in circles for days trying to get this to work and even though I have gone over the tutorials several times, I must have missed something. I have downloaded the code and compared but still cannot see where I might have gone wrong. In fact this whole thing includes my media root as well.
Could anyone provide any pointers? -
Very important – at 1:44 – use a COLON in between music:detail.
Easy typo to get stuck on… -
>>> from music.models import Album, Song
>>> a = Album.objects.get(id=1)
>>> a.artist
u'Taylor swift'why u is coming?
-
`app_name = 'music'` in music/urls.py does not work! only adding namespace in the project's urls.py works: `include('music.urls', namespace='music')`
-
This has been an excellent companion to the official django docs tutorial, though I would say if you're following that tutorial you should have kept the models the same i.e. polls instead of albums, would make it easier to code along. Anyhow, still a good companion video and I am learning, thanks!
-
very helpful thanks!
-
jango codes are hard to retain
-
I'm so new in anything programming, this is actually my first time and its been cool but I don't know what I'm getting wrong but the Http 404 shortcut isn't working for me
-
good stuff Bucky
-
Does "get_object_or_404()" have a 404 message parameter?
-
I have not seen the app_name approach here as used in the music.urls, the way I have seen elsewhere is adding a namespace to the main urls.py when you include the link to music.urls
i.e url(r'^music/', include('music.urls', namespace='music'),
-
where did you get that album_id?
-
First
Leave a Reply