I am trying to use Dropzone with Django, but I get a MultiValueDictKeyError
.
This is my html form:
<form action="{% url 'AlbumsManagerApp:album_add_photo' album_pk=album.id %}" class="dropzone" method="POST">
{% csrf_token %}
<div class="nav nav-bar">
<input type="submit" name="submit-accept" value="Aceptar" class="btn btn-success">
<input type="submit" name="submit-cancel" value="Cancelar" class="btn btn-danger">
</div>
</form>
This is my view:
class AlbumAddPhotoView(LoginRequiredMixin, View):
def get(self, request, album_pk):
album = Album.objects.get(id=album_pk)
context={'album': album }
return render(request, 'AlbumsManagerApp/form_upload.html', context)
def post(self, request, album_pk):
if 'submit-accept' in request.POST:
files = request.FILES['file']
print(files)
return redirect('AlbumsManagerApp:albums', album_pk=album_pk)
I followed the answer to the question Trying to use django and dropzone/, but I still get the same error.