Simple Django Image Upload - Image file not saving

前端 未结 3 1200
说谎
说谎 2021-02-11 05:42

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:35

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

提交回复
热议问题