19👍
If you are using UpdateView
, you only need to add enctype="multipart/form-data"
attribute to the form tag in your template. The rest will be handled by UpdateView
class.
6👍
You need to save the form providing request.FILES:
if request.method == 'POST':
form = MyForm(request.POST, request.FILES)
if form.is_valid():
form.save()
And in your HTML form (since you have an <input type="file">
in the form):
<form method="POST" enctype="multipart/form-data">
👤nima
- How to use custom password validators beside the django auth password validators?
- Celery periodic tasks not executing
- Django Rest Swagger APIView
Source:stackexchange.com