[old question]NoReverseMatch.. I am sorry.

87 views
Skip to first unread message

bruce

unread,
Aug 17, 2012, 5:24:38 PM8/17/12
to django...@googlegroups.com
I am sorry I know this is an old topics.
But I spent the whole day and still unable to fix this problem.

NoReverseMatch at /1/

Reverse for ''blog.views.add_comment'' with arguments '(1L,)' and keyword arguments '{}' not found.
Request Method:GET
Request URL:http://192.168.71.58:8007/1/
Django Version:1.4
Exception Type:NoReverseMatch
Exception Value:
Reverse for ''blog.views.add_comment'' with arguments '(1L,)' and keyword arguments '{}' not found.






The following is my urls.py


urlpatterns = patterns('',

url(r'^admin/', include(admin.site.urls)),
url(r'^(\d+)/$', 'blog.views.post'),
url(r'^add_comment/(\d+)/', 'blog.views.add_comment'),

)




my tempalte:

<form action="{% url 'blog.views.add_comment' post.id %}" method="POST">{% csrf_token %}
<div>
Name: {{ form.author }}
<p>{{ form.body|linebreaks }}</p>
</div>
<div><input type='submit' value='Submit'></div>
</form>




I tested the add_comment, it seems works.
http://192.168.71.58:8007/add_comment/1/
It works.



any idea?
Thanks!!!



Tomas Neme

unread,
Aug 17, 2012, 5:37:13 PM8/17/12
to django...@googlegroups.com
either remove the quotes from {% url 'blog.views.add_comment' %} (so it's {% url blog.views.add_comment %}) or {% load url from future %}

Loading from future is the better option, I think.

and for future reference:


Reverse for ''blog.views.add_comment'' with arguments '(1L,)' and keyword arguments '{}' not found.
notice how there's two single quotes there, not a double quote? that's your clue, right there

--
"The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny 
(")_(") to help him gain world domination.

bruce

unread,
Aug 17, 2012, 6:23:25 PM8/17/12
to django...@googlegroups.com
Tears!!!!!!!!!!!!!!!!!!!!!!!!
thanks!!!!!

But I am confused.
For example,
the following code needs to add single quote.
{% block content %}
<a href="{% url 'admin:todo_datetime_add' %}">Add Todo items</a>

Is there a link to give me detailed description?
I want to learn it and never get stuck again.

Thanks!!

Kurtis Mullins

unread,
Aug 17, 2012, 6:29:06 PM8/17/12
to django...@googlegroups.com
In this case, you are using a 'named URL' in the Admin namespace. Here's two links that may help you learn a bit more about this topic.

--
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/-/QqYvLl3VNisJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Tomas Neme

unread,
Aug 17, 2012, 6:30:26 PM8/17/12
to django...@googlegroups.com
> But I am confused.
> For example,
> the following code needs to add single quote.
>
> {% block content %}
> <a href="{% url 'admin:todo_datetime_add' %}">Add Todo items</a>

https://docs.djangoproject.com/en/dev/releases/1.3/#changes-to-url-and-ssi

also, that won't work with double quotes either, unless you import
future, and a bunch of other things.

Just import url from future, since this will be the default behavior
in the near future
Message has been deleted

bruce

unread,
Aug 17, 2012, 6:46:28 PM8/17/12
to django...@googlegroups.com
Thanks.
I am going to read it.
Have a great weekend!
Reply all
Reply to author
Forward
0 new messages