Search code examples
pythondjangourlslug

URL with 'slug' doesnt load the view


I have the url configurated on

url(r'^tags/(?P<slug>\d+)/$', TagsDetailList.as_view(), name = 'tag_detail'),

now if i enter the url /tags/bubble (its given in the tag_list and has a related object) the back should load TagsDetailList View?

class TagsDetailList(ListView):
    queryset = Link.objects.filter(tags__name__in=['request.slug'])
    template_name = "tags_detail_list.html"

But it didnt reach the view cause i get Page not found Error. Why?

Remote Address:127.0.0.1:8000
Request URL:http://127.0.0.1:8000/tags/bubble
Request Method:GET
Status Code:404 NOT FOUND
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4,it;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
Cookie:csrftoken=yY4hznFWlnvDbvvgBFWupYsrDFse32Pe; sessionid=0zx2ot6962wpx66ovmlk0z08gd5zvxho
DNT:1
Host:127.0.0.1:8000
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)         Chrome/38.0.2125.104 Safari/537.36
Response Headersview source
Content-Type:text/html
Date:Sun, 26 Oct 2014 10:47:50 GMT
Server:WSGIServer/0.1 Python/2.7.6
Vary:Cookie
X-Frame-Options:SAMEORIGIN

didnt get it. thanks


Solution

  • \d matches against digits only. You need \w.