Fengson
Fengson

Reputation: 4912

Add comment to a post - NoReverseMatch error

I am building a website with a simple blog. I follow the instructions from: http://lightbird.net/dbe/blog.html I got to a point where I see posts, but then he adds links to each post. I added :

(r"^(\d+)/$", "post"),

to my urls.py and when I added : <a href="{% url 'news.views.post post.pk' %}">Comments</a> everything breaks. It's like it's not sending the value. I think I am doing something wrong with the links..

Can anyone check my app? Admin account : admin/admin. Wrong code is in: templates/news/list.html When I delete that line it works.

Here is my code: https://db.tt/b7qpib28

TRACEBACK : http://dpaste.com/1471932/

Upvotes: 0

Views: 73

Answers (2)

juliocesar
juliocesar

Reputation: 5876

You need to remove the $ in url pattern that includes news.urls, so in Uploader/uploader/uploader/urls.py change the line 32:

(r"^news/$", include('news.urls')),

by this

(r"^news/", include('news.urls')),

That's all ;) ...this obstruct the rest of url, you can display the url for news.views.main because it didn't add anything to the url but news.views.post need to add the pk parameter

Upvotes: 3

Alasdair
Alasdair

Reputation: 309109

Firstly, your closing single quote is I the wrong place. Secondly, try using the url pattern name instead of the path to the view.

Try the following:

{% url 'post' post.pk %}

Upvotes: 2

Related Questions