urls.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.
答案 0 :(得分:4)
news_type
应该是一个整数,但你传递了字符串(unicode),所以它失败了。