gamer
gamer

Reputation: 5863

How to access media files in django

In my settings I have

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

my uploaded files are saved in media folder..

In my template now I want to access these files

<img src="{{MEDIA_URL}}{{file.my_file}}" width="100" height="100" /></a>

When I do this its not showing the images or file.How can I get the file.. What should I use ?

Upvotes: 1

Views: 3452

Answers (1)

pptt
pptt

Reputation: 705

what i have set in settings.py: MEDIA_ROOT = '/home/paulius/django-paulius/epc/static/'

there i have several folders for my static files. one of them is for uploaded files. in my template i would write: <p><a href="/static/assets/{{patient.thumbnail}}">FILE</a></p>

this one works. i am using it right now. try checking the url to your files, maybe you misprinted something

Upvotes: 1

Related Questions