1 2 3 4 5 6 7 8 9 10 11 | from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.filter
@stringfilter
def media_url(value,MEDIA_URL):
"""Searches for {{ MEDIA_URL }} and replaces it with the current MEDIA_URL"""
return value.replace('{{ MEDIA_URL }}', MEDIA_URL)
media_url.is_safe = True
|
More like this
- Use MEDIA_URL in flatpages by robhudson 5 years, 2 months ago
- Load static media from secure (SSL) static server (Context Processor) by ianreardon 3 years, 7 months ago
- Cycling MEDIA_URL context processor by girasquid 4 years, 5 months ago
- media_url context variable by marchino 6 years, 1 month ago
- Use MEDIA_URL in 500 error page by bthomas 4 years, 6 months ago
Comments