首页 > 解决方案 > 无法在 Django 表单中访问 Div 中的字段

问题描述

什么工作正常

<form action = "{% url 'dashboard'%}" method = "POST">
    {% csrf_token %}
    <label for="your_name">Your name: </label>
    <input id="your_name" type="text" name="your_name">
    <input type="submit" value="OK">
</form>

什么不起作用...

<form action = "{% url 'dashboard'%}" method = "POST">
    {% csrf_token %}
     <div class="col-lg-3 col-md-3 col-sm-12 p-0">
        <input type="text" id="cve" class="form-control search-slt" placeholder="Enter CVE">
        <input type="submit" value="OK">
    </div>
</form>

每当我在DIV标签内有值时,在 a 内formPOST请求不包含 DIV 字段的值。

标签: djangodjango-forms

解决方案


推荐阅读