如何使用循环从 Django 中的 html 模板请求

问题描述

从 html 模板说“createlist”我想添加链接,该链接实际上请求服务器将图像形式的另一个对象添加到“createlist”页面。但是当我运行代码时,它实际上只发生一次,但我希望最多 5 次,这应该被接受。所以在这里我如何在 html 模板中使用循环,以便它一次又一次地获得请求,直到限制说 5。 这是模板代码 -

try {
    $stmt = $db->prepare("SELECT * FROM `season` WHERE season.show_id = '" . $show_id . "' ORDER BY season_number DESC");
    // how to select episodes_count?
    $stmt->execute();
    $seasons = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    echo $e;
}

查看功能


    {% if morepicform %}
        {{ morepicform }}
    {% endif %}
    Want to add more pics? <a href="{% url 'createlist' 'morepic' %}" role="button">
    <img src="static/auctions/plus-circle-solid.svg" height="20px" width="20px"></a>

url模式路径函数-

def morepic(request,morepic=''): return render(request,"auctions/createlist.html",{ "morepicform" : PictureForm(),"picform" : PictureForm(),"listform" : ListingForm() })

现在如何添加请求“morepicform”的功能

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)