Search code examples
djangofileupload

django upload file no model


Is it possible to upload a file in django with a FileField in a form but no model? So far I could only find examples with a model. I don't want to create a table for that in my database, I just want to upload a file. My form:

class csvUploadForm(forms.Form):
    csvFile = forms.FileField(label='Select a CSV file to upload.', help_text='help')

Thank you,

Romain


Solution

  • This is covered in the File Uploads section of the Django documentation. In short, use the UploadedFile instance given in request.FILES.