diff --git a/django_weasyprint/utils.py b/django_weasyprint/utils.py index bb96386..607b56c 100644 --- a/django_weasyprint/utils.py +++ b/django_weasyprint/utils.py @@ -31,7 +31,13 @@ def django_url_fetcher(url, *args, **kwargs): elif settings.STATIC_URL and url_path.startswith(settings.STATIC_URL): path = url_path.replace(settings.STATIC_URL, '', 1) - data['file_obj'] = open(find(path), 'rb') + found_path = find(path) + if not found_path: + path = Path( + settings.STATIC_ROOT / url_path.replace(settings.STATIC_URL, '', 1) + ) + found_path = f'{path}' if path.is_file() else None + data['file_obj'] = open(found_path, 'rb') return data # fall back to weasyprint default fetcher