[Answer]-Accessing downloaded files in template

1👍

You need add MEDIA_URL with TEMPLATES_CONTEXT_PROCESSORS or just write simple template tag like this (https://docs.djangoproject.com/en/dev/howto/custom-template-tags/):

import os

from django.template import Library
from django.conf import settings


register = Library()


@register.simple_tag
def media_url(filename):
   return os.path.join(settings.MEDIA_URL, filename)

And then you can use it like this:

{% load utils_tags %}

{% media_url 'data/saved_files/myfile.png' %}
👤ssbb

Leave a comment