V
V
Vadim kyklaed2018-04-24 22:17:23
Django
Vadim kyklaed, 2018-04-24 22:17:23

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

1 answer(s)
P
Pavel Aksenov, 2018-04-25
@hellmin

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 question

Ask a Question

731 491 924 answers to any question