我的模板文件中有这个:
<a href="{% url polls.views.vote poll.id %}">Vote again?</a>
这是我的 URLConf:
urlpatterns = patterns('polls.views',
url(r'^$', 'index'),
url(r'^(?P<poll_id>\d+)/$', 'detail'),
url(r'^(?P<poll_id>\d+)/results/$', 'results'),
url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
我更改了一些视图以使用泛型:
urlpatterns = patterns('polls.views',
url(r'^$',
ListView.as_view(
queryset=Poll.objects.order_by('-pub_date')[:5],
context_object_name='latest_poll_list',
template_name='polls/index.html')),
url(r'^(?P<pk>\d+)/$',
DetailView.as_view(
model=Poll,
template_name='polls/details.html')),
url(r'^(?P<pk>\d+)/results/$',
DetailView.as_view(
model=Poll,
template_name='polls/results.html'),
name='results'),
url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
现在显示此错误:
未找到带有参数“(1,)”和关键字参数“{}”的“polls.views.results”的反向操作。
我怎样才能解决这个问题?