Commit 8ea6a5b3 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

use absolut url, usefull when exporting views to pdf

parent 7ab5663b
Pipeline #40114 failed with stage
in 1 minute and 37 seconds
...@@ -11,16 +11,20 @@ from django.core.cache import cache ...@@ -11,16 +11,20 @@ from django.core.cache import cache
register = template.Library() register = template.Library()
@register.simple_tag @register.simple_tag(takes_context=True)
def sstatic(path): def sstatic(context, path):
url = cache.get(path) url = cache.get(path)
if url: if url:
return 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) cache.set(path, url, None)
return url return url
def get_absolut_url(request, relative_url):
return f"{request.scheme}://{request.get_host()}{relative_url}"
def compute_url_for_path(path): def compute_url_for_path(path):
''' '''
Returns absolute URL to static file with versioning. Returns absolute URL to static file with versioning.
...@@ -7,7 +7,7 @@ readme = open('README.rst').read() ...@@ -7,7 +7,7 @@ readme = open('README.rst').read()
setup( setup(
name='django-basetheme-bootstrap', name='django-basetheme-bootstrap',
version='0.2.40', version='0.2.41',
description='Django Basetheme Bootstrap', description='Django Basetheme Bootstrap',
long_description=readme, long_description=readme,
author='Bryan Brancotte', author='Bryan Brancotte',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment