【发布时间】:2020-03-02 18:58:01
【问题描述】:
我在模型中有一个 Imagefield,在我的表格中,该字段显示为链接,但是当您单击它时,它会指向 url,而我想下载它。我发现在 html 中你可以像这样添加“下载”属性:
<a href="/media/pictures/CFE.JPG" download></a>
所以在我的 django-tables2 中:
tables.py
class PagosDetailTable(tables.Table):
imagen = tables.Column(
attrs={"td": {"href": "download"}})
class Meta:
model = Pagos
template_name = "django_tables2/bootstrap-responsive.html"
fields = ('carro', 'semana', 'fecha', 'pago', 'imagen')
attrs = {"class": "table table-hover table-sm"}
但它会覆盖 href:
<a href="download"></a>
有没有办法使用 tables.Column 附加下载属性?
【问题讨论】:
标签: django django-models django-tables2