Saturday, September 1, 2012

matching a name in url

Hello all, I'm still new to django and I'm having a little problem with the url matching.

here is my line of code
    url(r'^comment/allcomments/(?P<commentName>[-\w]+)/all/$', 'comment.views.allUserComments'),

def allUserComments(request, commentName):
    userComments = Post.objects.get(name=commentName)
    return render_to_response('/comment/comments.html', { 'Post': userComments })


what i want it to do is similar to the Poll tutorial on https://www.djangoproject.com/, but I can't seem to get it to work. I keep getting the following after clicking on the user "name"

Using the URLconf defined in Sampleblog.urls, Django tried these URL patterns, in this order:

  1. ^$ [name='home']
  2. ^comment/allcomments/(?P<commentName>[-\w]+)/all/$
  3. ^comment/comments.html$ [name='comment']
  4. ^static/(?P<path>.*)$
  5. ^admin/doc/
  6. ^admin/

The current URL, comment/mando/all/, didn't match any of these.


the comment page shows this with a link for the "name"
Last 5 Comments....
mando - said on Sept. 1, 2012, 5:18 p.m....
Testing 2

mando - said on Sept. 1, 2012, 5:17 p.m....
Testing 12

mando - said on Sept. 1, 2012, 5:17 p.m....
 1

is there something i'm missing here? Any suggestions are greatly appreciated

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/D-skLJUDiP4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment