Django Tutorial for Beginners - 21 - Namespace and HTTP 404 Shortcut

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

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!

deborah_chrysoprase
Автор

For those of you using v2.1 in your music/urls.py include app_name= 'music' and also in your project's urls.py add namespace in the include function: include('music.urls', namespace='music')

KatanaHSM
Автор

Wow, it makes a whole lot more sense now why you make a url file in each app. Thanks Bucky!

CharleswoodSpudzyofficial
Автор

Your Tutorials are very clear and anyone can learn Python. Thank you very much. Good for new gen.

ant
Автор

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'),

smoothbeak
Автор

dude you are AWESOME, the best videos ever ! thanks!

davcastroruiz
Автор

Can someone help me, i got stuck.

Reverse for 'detail' with arguments '(1, )' and keyword arguments '{}' not found. 0 pattern(s) tried: []
my code:
<li><a href = "{% url 'music:detail' album.id

mgroend
Автор

Does "get_object_or_404()" have a 404 message parameter?

CSryandm
Автор

`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')`

ratulotron
Автор

<li><a href = "{% url 'music:detail' album_id
the error is in this line

RameshPatil-mrrl
Автор

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

kojakeugenio
Автор

I am using django 2.0, the error I am getting is “Reverse for 'music:detail' not found. 'music/detail' is not a valid view function or pattern name.” Someone help.

shubhampatil
Автор

I followed the tutorial and get the error that Reverse for 'detail' with arguments '('', )' and keyword arguments '{}' not found. 1 pattern(s) tried: Does anyone know how to fix that?

mikezhang
Автор

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

adarshkadameri
Автор

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.

sonikajha
Автор

Hi Bucky, one doubt
we have to change
url in line 16 and give app_name = 'music'
in views.py also no??

amitlathwal
Автор

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 .

RamisaAnjum
Автор

Kind of stuck on a small bit, if album.id is already in the "detail" url structure, why do we have to specify it again in this line '{% url 'detail' album.id %} ? thanks for all of your videos

brotherx
Автор

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?

DaveJohns
Автор

>>> from music.models import Album, Song
>>> a = Album.objects.get(id=1)
>>> a.artist
u'Taylor swift'

why u is coming?

anushilkumar