Answer the question
In order to leave comments, you need to log in
How to upload and download a file?
Hello, can you tell me how to upload the file?
i upload with models.FileField(upload_to='invoice/',null=True,blank=True)
and MEDIA_ROOT = os.path.join(BASE_DIR, 'file/')
the file is uploaded where it should. and how to upload multiple files?
if this method is correct, then why in the description of dzhanga a method is described with writing a view and a form. if so it works?
and how to download the file?
Answer the question
In order to leave comments, you need to log in
You need to specify MEDIA_URL .
For the field in which the file record is stored, you need to display the value of the url attribute in the template ( Example ).
To upload multiple files to one material, you need to use formsets .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question