python - Django: getting NoReverseMatch at / error -
there lot of similar issues on , went through of them, still unable resolve problem.
i getting following error:
reverse 'category_view' arguments '()' , keyword arguments '{'pk': 'dynamic-programming'}' not found. 0 pattern(s) tried: [] noreversematch @ /articles/
here settings urls.py file:
url(r'^category/(?p<pk>[\w-]+)/$', views.categorydetailview.as_view(), name='category_view')
and, definition of get_absolute_url() model;
def get_absolute_url(self): return reverse('category_view', kwargs={'pk': self.slug})
and caller getting error index.html:
<li><a href="{{ category.get_absolute_url }}">{{ category.name }}</a></li>
i sure missing obvious, not able figure out past few hours. :(
content project's urls.py:
url(r'^articles/$', include('blog.urls', namespace="blog")), url(r'^admin/', include(admin.site.urls)),
i suspect forgot include urls.py
app project's urls.py
.
update: if used namespace
parameter of include have specify namespace in reverse()
call:
def get_absolute_url(self): return reverse('blog:category_view', kwargs={'pk': self.slug})
Comments
Post a Comment