Had a more general question. I want to make an app that you upload a .csv file to, then the app generates a new csv, then you download it.
What would be the best approach for this?
Would you recommend using models, or is there a simple way to use POST without models? I’ve had a look at the documentation but it is a bit beyond me. I’d appreciate any advice on the general approach you can give. Thanks
Your view would display a form with a FileField. On submit, your view would accept a file, read it, generate the output file, and then (possibly) return a FileResponse.
Thanks so much for your answer. It would be transient processing. Thanks for your help.
So I’ve been trying your suggestion. However, I have two problems. First, I can’t seem to select the file from the request.FILES. I keep getting a MultiValueDictKeyError.
from django import forms
from .models import ArrayCsv
class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file = forms.FileField()
Your views here don’t match the patterns of code as shown in the docs I referenced.
I suggest you start simple by following the docs as closely as possible before changing the patterns being used in the code, until you get to the point where you’re understanding what’s going on.