When uploading files from a form, it keeps throwing a error that the destination could not be found. I think it's obvious, because I open() the path for the file where there is no path yet, so kind of a forward reference i guess. But it's how I read it in the Django docs.
def form_valid(self, form):
for index, image in enumerate(self.request.FILES.items()):
with open(os.path.join(settings.MEDIA_ROOT,'image', str(index), 'image.jpg')) as path:
for chunk in image.chunks():
path.write(chunk)
return super().form_valid(form)
So nothing special, I just try to upload images from forms from the html. It throws this error:
Exception Type: FileNotFoundError
Exception Value:
[Errno 2] No such file or directory: '/path/to/my/project/media/image/0/image.jpg'