Django enctype=“multipart/form-data” not setting P

2019-05-21 00:56发布

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?

1条回答
地球回转人心会变
2楼-- · 2019-05-21 01:31

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>.

查看更多
登录 后发表回答