以下是发送请求的HTML,打印request.FILES
返回<MultiValueDict: {}>
。
另外我会问我如何保存我的收费图片(仅适用于form.save()
?)
<form action="send_news" method="POST" encrypt="multipart/form-data">
{% csrf_token %} {{ form.as_p }}
<p>
<label for="news_title">Your name: </label>
<input id="news_title" type="text" name="news_title" value="newtitle">
</p>
<p>
<label for="news_small_description">Your name: </label>
<input name="news_small_description" id="news_small_description" value="news_small_description">
</p>
<p>
<label for="news_description">Your name: </label>
<input name="news_description" id="news_description" value="news_description">
</p>
<p>
<label for="news_image">Your name: </label>
<input id="news_image" type="file" class="" name="news_image">
</p>
<input type="submit" value="Submit" />
</form>
打印request.FILES返回<MultiValueDict: {}>
。
另外我会问我如何保存我的收费图片(仅适用于form.save()
?)
答案 0 :(得分:0)
问题是您使用的是encrypt
,但您需要使用enctype
e.g。
<form action="send_news" method="POST" enctype="multipart/form-data">
如果需要,请参阅What does enctype='multipart/form-data' mean?了解更多信息。