0

网址.py

urlpatterns = patterns('',
    url(r'^$', 'entertainment_website.views.index'),
    url(r'^story/(?P<news_type>\d+)/(?P<story_id>\d+)', 'entertainment_website.views.story'),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

网址创建:

<h2 class="main_story_headline"><a href="{% url entertainment_website.views.story story_id=story.id news_type=story.news_type %}">{{ story.title }}</a></h2>

我做错了什么导致以下错误:

NoReverseMatch at /
Reverse for 'entertainment_website.views.story' with arguments '()' and keyword arguments '{'story_id': 690, 'news_type': u'nightlife'}' not found.
4

1 回答 1

4

news_type应该是一个整数,但是你传递了字符串(unicode)所以它失败了。

于 2013-05-03T13:32:00.120 回答