1👍
Set your MEDIA_ROOT
in settings.py . You can try MEDIA_ROOT=BASE_DIR+'/media'
. After that create your media url in settings.py as MEDIA_URL='/media/'
. Then in template you can mention download url as src="{{MEDIA_URL}}/<DATE STRING HERE>"
check Django docs on media files here and static files here. It is better to setup a model in your app’s models.py to handle file uploads. A typical model looks like below.
class ExcelUploads(models.Model):
excel_file = models.FileField(upload_to='/media/excel_files')
description = models.CharField(max_length=255)
def __unicode__(self):
return self.description
To provide download links for your excel files, make use of {% static %} template tag
or {{MEDIA_URL}}
after adding django.template.context_processors.media to your 'context_processors' under TEMPLATES section of settings.py
.static tags are usually used to serve static files like css, js etc. Its good to use media_url to serve file downloads.
So based on the model definitions in the answer posted, your download links looks like src="{{MEDIA_URL}}/{{ExcelUploads[0].excel_file.url}}"