如何从html更新django数据库?

如何从html更新django数据库?,django,django-forms,Django,Django Forms,我只想更新品牌。所以我想看看我是否能从输入中得到帖子。 print(request.POST.get('brand'))没有打印任何内容,但我可以打印(request.POST.get('url'))。有人知道为什么吗? 这是我的base.html代码 <form action="{% url 'script' %}" method="POST" enctype="multipart/form-data"> {% csrf_token %} <div class

我只想更新品牌。所以我想看看我是否能从输入中得到帖子。 print(request.POST.get('brand'))没有打印任何内容,但我可以打印(request.POST.get('url'))。有人知道为什么吗? 这是我的base.html代码

<form action="{% url 'script' %}" method="POST" enctype="multipart/form-data">
    {% csrf_token %}
    <div class="form-group w-75">
        <input type="text" name="url" id="url" class="form-control">
    </br>
    <button type="submit" class="btn btn-success btn-lg btn-block">submit</button>
</div>
</br>

{% if alldata %}


<table class="table table-striped table-sm" id="">
    <thead>
        <tr>
            <th>Price</th>
            <th>Asin</th>
            <th>Rank</th>
            <th>Brand</th>
            <th>CPU</th>
            <th>Update</th>
        </tr>
    </thead>
    <tbody>
        {% for data in alldata %}
        <tr>
            <td>{{ data.price }}</td>
            <td> <a href="{{ data.link }}">{{ data.asin }}</a> </td>
            <td>{{ data.rank }}</td>

            <td>    
                <div>
                {{ data.brand }} <input type="text" name="brand" id="brand" value="{{data.brand}}">
                <button type="submit">Update</button>
                </div>
            </td>
            <td>cpu</td>
            <td><button type="submit">Update</button></td>
        </tr>
        {% endfor %}

    </tbody>
</table>

{% endif %}

</form>

{%csrf_令牌%}

提交
{%if alldata%} 价格 阿辛 等级 烙印 中央处理器 更新 {%用于alldata%中的数据} {{data.price}} {{data.rank} {{data.brand}} 更新 中央处理器 更新 {%endfor%} {%endif%}
要检查request.POST中的所有数据:

print(request.POST)
只打印一个“字段”

print(request.POST['field'])

您是否尝试过使用
打印(request.POST.getlist('brand'))
?显示您的功能。我需要看看什么是
alldata
,以及您可能犯的任何其他错误。