我想我在这里遗漏了一些明显的东西,但是我已经坚持这么久了,我不得不发布这个问题。
urls.py:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'admin', views.admin, name='admin'),
url(r'admin/edit/(?P<pk>\d+)/', views.bug_edit, name='bug_edit'),
url(r'admin/delete/(?P<pk>\d+)/', views.bug_delete, name='bug_delete'),
)
views.py:
def bug_edit(request):
return HttpResponse('This is an edit page!')
def bug_delete(request):
return HttpResponse('This is a delete page!')
forms.py:
class SimpleTable(tables.Table):
edit_link = tables.LinkColumn('bug_edit', args=[A('pk')],
verbose_name='Edit', accessor='pk', attrs={'class':'edit_link'})
delete_link = tables.LinkColumn('bug_delete', args=[A('pk')],
verbose_name='Delete Bug', accessor='pk', attrs={'class':'delete_link'})
class Meta:
attrs = {'class' : 'paleblue'}
model = BugModel
我没有按照我的意愿点击链接看到HttpResponse。
谢谢。
答案 0 :(得分:2)
问题是您的网址模式缺少^和$。
没有它们,管理员就可以了。模式匹配任何网址与&#39; admin&#39;在其中 - 有效地掩盖了以下模式。
请尝试使用此代码:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^admin/$', views.admin, name='admin'),
url(r'^admin/edit/(?P<pk>\d+)/$', views.bug_edit, name='bug_edit'),
url(r'^admin/delete/(?P<pk>\d+)/$', views.bug_delete, name='bug_delete'),
)