diff --git a/basetheme_bootstrap/templatetags/sstatic.py b/basetheme_bootstrap/templatetags/sstatic.py index 861fbafb84a69ff1f87e5f8c82d454f7f66104a4..3c364b1546faa6d8fc092c34dd688d85418037e3 100644 --- a/basetheme_bootstrap/templatetags/sstatic.py +++ b/basetheme_bootstrap/templatetags/sstatic.py @@ -11,16 +11,20 @@ from django.core.cache import cache register = template.Library() -@register.simple_tag -def sstatic(path): +@register.simple_tag(takes_context=True) +def sstatic(context, path): url = cache.get(path) if url: return url - url = compute_url_for_path(path) + url = get_absolut_url(context["request"], compute_url_for_path(path)) cache.set(path, url, None) return url +def get_absolut_url(request, relative_url): + return f"{request.scheme}://{request.get_host()}{relative_url}" + + def compute_url_for_path(path): ''' Returns absolute URL to static file with versioning. diff --git a/setup.py b/setup.py index 764c97bae0f802014682e2fc847a7890d2de3d87..62f8060085a4647fa498d4c201dd88a8834e4c48 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ readme = open('README.rst').read() setup( name='django-basetheme-bootstrap', - version='0.2.40', + version='0.2.41', description='Django Basetheme Bootstrap', long_description=readme, author='Bryan Brancotte',