Django - Custom inclusion template tag MEDIA_URL?

I have the following custom inclusion tag:

from django.template import Library
from django.db.models import Count

register = Library()

@register.inclusion_tag('projects/work_part.html', takes_context=True)
def project_list(context):
    return {'projects':context['projects']}

My settings look like this:

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'context_processors.default_processors',
    )

I need to access MEDIA_URL within the work_path.html template but it seems the context processors are not applied to custom templates.

How do I access MEDIA_URL within my template tag? I saw this post: Access STATIC_URL from within a custom inclusion template tag but I am not using STATIC_URL, is there another set of tags I should be loading?

7
задан Community 23 May 2017 в 12:33
поделиться