Simple Django Image Upload - Image file not saving

前端 未结 3 1315
走了就别回头了
走了就别回头了 2021-02-11 05:56

Right I\'m learning how to do a simple image upload form to upload an image to MEDIA_ROOT. The form renders fine, I get no errors, but the file is not showing up in the MEDIA_RO

3条回答
  •  情歌与酒
    2021-02-11 06:27

    In order to have your files uploaded and shows in request.FILES, your form MUST contain enctype="multipart/form-data" as shown below:

    {% csrf_token %} {{ form.image }}

提交回复
热议问题