【发布时间】:2020-03-06 09:45:00
【问题描述】:
我是 Django 新手。 所以基本上我已经在我的 HTML 页面中创建了一个卡片视图。
当我单击下载按钮时,应创建 HTML 卡的图像文件 (PNG)(如图所示)并将其保存到数据库中。 下载的图像应该在 django 项目的 media/cardimage 文件夹中。 图片如下所示。(截图)card image HTML代码如下所示
我怎样才能完成这项任务? 非常感谢任何人的帮助。
谢谢。
<div class="container">
<div class="col" >
<div class="col-lg-4 d-flex align-items-stretch" >
<div id="html-content-holder" class="card rounded-lg shadow bg-white rounded" style="width: 25rem; width: 50vw; margin:auto;">
<div class="overlay">
<img class="card-img-top" src="{% static 'images/ab_nba_040320.jpg' %}" alt="Card image cap">
</div>
<!-- Card content -->
<div class="card-body">
<!-- Title -->
<div style="text-align: left;">
<h4 class="card-title font-weight-bold align-left">
<p style="font-size: 80%;">NBA: Davis sparks Lakers over Sixers with hot second quarter, LeVert hits career-best 51pts as Nets beat Celtics
<a id="btn-Convert-Html2Image" class="fa fa-download" aria-hidden="true" style="cursor: pointer;" title="Download"></a>
</p>
</h4>
<!-- Text -->
<p class="card-text" style="font-size: 85%;">Anthony Davis produced a devastating burst of scoring, as the Los Angeles Lakers came from behind to defeat the Philadelphia 76ers 120-107 on Tuesday (March 3) in their National Basketball Association (NBA) game.
He led the Lakers' surge with 37 points at the Staples Centre after the hosts recovered from a slow start to run out convincing winners.</p>
<p style="font-size: 70%; opacity: 30%;">Published Date: 05 Mar 2020</p>
</div>
<img class="" style="width: 30%; height: auto; margin-bottom: -5%;" src="{% static 'images/cover.png' %}" alt="Card image cap">
</div>
</div>
</div>
</div>
</div>
【问题讨论】: