[Fixed]-Django upload image file from templates

1👍

First, you will need to add enctype="multipart/form-data" in your <form> definition. As this is required for file uploads.

<form role="form" action="" method="post" enctype="multipart/form-data">

Second, instead of form_class(request.POST) you will need to create form in your view by passing request.FILES too.

form_class(request.POST, request.FILES)

Leave a comment