0

Here is my HTML sending the request, printing request.FILES return <MultiValueDict: {}>. Also i would ask how can i save my charged picture (is ok to only 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>

printing request.FILES return <MultiValueDict: {}>. Also i would ask how can i save my charged picture (is ok to only form.save()?)

Dev9977
  • 731
  • 2
  • 8
  • 20

1 Answers1

2

The problem is you are using encrypt but you need to use enctype

e.g.

<form action="send_news" method="POST" enctype="multipart/form-data">

See What does enctype='multipart/form-data' mean? for more info if needed.

Tom Dalton
  • 5,347
  • 17
  • 29