Django enctype =" multipart / form-data"不设置POST数据 [英] Django enctype="multipart/form-data" not setting POST data

查看:283
本文介绍了Django enctype =" multipart / form-data"不设置POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是我正在处理的表单:

 < form method =postaction ={%url catalog_create_ajax_upload%}enctype =multipart / form-dataid =create-form > 
< input type =textid =new-catalog-namename =catalog_nameclass =large-inputplaceholder =catalog title/>
< div id =new-catalog>
< input type =filename =file>
< / div>
< / form>

发送时,我忽略 request.POST ['catalog_name'] 有一个值,但整个POST属性在一个空的字典中。



有什么帮助?

解决方案

您似乎没有提交按钮的形式。假设你在页面的其他地方有一个,但是它只能以自己的形式提交这个字段 - 把它移到< form> ...< / form>


I need to send both a file and some data from input texts.

This is the form I'm working on:

    <form method="post" action="{% url catalog_create_ajax_upload %}" enctype="multipart/form-data" id="create-form">
        <input type="text" id="new-catalog-name" name="catalog_name" class="large-input" placeholder="catalog title" />
        <div id="new-catalog">
            <input type="file" name="file">
        </div>
    </form>

When sent, I excpect request.POST['catalog_name']to have a value, but the whole POST attribute in an empty dictionary.

Any help?

解决方案

You don't seem to have a submit button in that form. Presumably you've got one elsewhere on the page, but it would only submit the fields in its own form - move it inside that <form>...</form>.

这篇关于Django enctype =&quot; multipart / form-data&quot;不设置POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆