我的应用程序显示一个包含许多列的表格。我使用Django表格2应用程序来呈现表格。我试图让一列中的项目超链接,以便用户可以点击。 url模式很简单:/contact/pk/
,例如/contact/2/
。这是我在我的模型中有:Django表格2:超链接列中的项目
#models.py
class Contact(models.Model):
name = models.CharField(max_length=200)
. . .
class ContactTable(tables.Table):
name = tables.LinkColumn('contact_detail', args=[A('pk')])
class Meta:
model = Contact
attrs = {"class": "paleblue"}
#urls.py
url(r'^contact/(?P<item_id>\d+)/$', 'app.views.contact_view', name='contact_detail'),
但是,项目不会超链接。
我认为这将有助于你: http://stackoverflow.com/questions/8613542/the-linkcolumn-about-django-tables2 – catherine 2013-02-09 07:29:34