Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch static from relative path too #49

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion django_weasyprint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down