diff --git a/idre/urls.py b/idre/urls.py index 719e18d..b946bac 100644 --- a/idre/urls.py +++ b/idre/urls.py @@ -11,9 +11,9 @@ admin.autodiscover() urlpatterns = patterns("", url(r"^$", label.views.home, name = "home"), url(r"^artists/$", "label.views.artists", name = "artists"), - url(r"^artists/(?P\d+)$", "label.views.artist", name = "artist"), + url(r"^artists/(?P\S+)$", "label.views.artist", name = "artist"), url(r"^releases/$", "label.views.releases", name = "releases"), - url(r"^releases/(?P\d+)$", "label.views.release", name = "release"), + url(r"^releases/(?P\S+)$", "label.views.release", name = "release"), url(r"^admin/", include(admin.site.urls)), ) diff --git a/label/templates/label/artists.html b/label/templates/label/artists.html index fc22b63..253754a 100644 --- a/label/templates/label/artists.html +++ b/label/templates/label/artists.html @@ -13,7 +13,7 @@ {% for artist in artists %} - +
{{ artist.name }}
diff --git a/label/views.py b/label/views.py index 77382eb..bdea82e 100644 --- a/label/views.py +++ b/label/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render from label.models import Artist, Release import label.tools as tools @@ -14,8 +14,8 @@ def artists(request): return render(request, "label/artists.html", context) -def artist(request, aid): - artist = Artist.objects.get(id = aid) +def artist(request, slug): + artist = get_object_or_404(Artist, slug = slug) releases = artist.release_set.all() context = { "artist": artist, "releases": releases } return render(request, "label/artist.html", context)