From dd1c2696b52a59d1c44359f058824feb447de9ef Mon Sep 17 00:00:00 2001 From: Igor Koshkarov Date: Wed, 29 Aug 2018 09:51:10 +0300 Subject: [PATCH 1/2] Avoid non existing STATIC_ROOT When Django DEBUG mode is on, I get an error because in the debug mode there is no STATIC_ROOT setting. In the proposed changes I made a workaround of this issue. --- wkhtmltopdf/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index 2a17bcb..e8308f9 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -284,7 +284,7 @@ def make_absolute_paths(content): 'url': settings.MEDIA_URL, }, { - 'root': settings.STATIC_ROOT, + 'root': settings.STATIC_ROOT if not settings.DEBUG else settings.STATICFILES_DIRS[0], 'url': settings.STATIC_URL, } ] From cfa1b4d4dede7a970b987dfd07770c63ab46045e Mon Sep 17 00:00:00 2001 From: Igor Koshkarov Date: Wed, 29 Aug 2018 11:31:19 +0300 Subject: [PATCH 2/2] Update utils.py If staticfiles_dirs is empty then return '' --- wkhtmltopdf/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index e8308f9..fd4826e 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -284,7 +284,8 @@ def make_absolute_paths(content): 'url': settings.MEDIA_URL, }, { - 'root': settings.STATIC_ROOT if not settings.DEBUG else settings.STATICFILES_DIRS[0], + 'root': settings.STATIC_ROOT if not settings.DEBUG else settings.STATICFILES_DIRS[0] if len( + settings.STATICFILES_DIRS)>0 else '', 'url': settings.STATIC_URL, } ]