Reputation: 33655
Can someone explain what this error means and how to solve?
This is the error message:
**NoReverseMatch at /contacts/group/new/ Reverse for ''group_list'' with arguments '()' and keyword arguments '{}' not found.**
the urls.py
urlpatterns = patterns('',
url(r'^$', 'contacts.views.home', name="group_list"),
(r'^group/new/$', 'contacts.views.group', {}, 'group_new'),
(r'^group/edit/(?P<id>\d+)/$', 'contacts.views.group', {}, 'group_edit'),
)
the template.py
<li>
<a href="{% url 'group_list' %}">
<i class="icon-group"></i>
<span>Contacts</span>
</a>
</li>
Upvotes: 0
Views: 139
Reputation: 34593
You can clean your patterns up a bit by leveraging the prefix
argument:
urlpatterns = patterns('contacts.views',
url(r'^group/edit/(?P<id>\d+)/$', 'group', name='group_edit'),
url(r'^group/new/$', 'group', name='group_new'),
url(r'^$', 'home', name="group_list"),
)
and when you use the url template tag, just provide the name of the pattern, instead of handing in a string literal to the function:
{% url group_list %}
Since patterns are matched in order, I would recommend putting the most specific patterns first, otherwise you might get some unexpected behavior.
Upvotes: 2