简体   繁体   English

uwsgi + wkhtmltopdf + Django不起作用

[英]uwsgi + wkhtmltopdf + Django not works

I create a deployment of Django application with nginx and uwsgi. 我使用nginx和uwsgi创建了Django应用程序的部署。 Where I try access to page rendered in pdf with wkhtmltopdf print the following error: 在我尝试使用wkhtmltopdf访问以pdf呈现的页面的地方,出现以下错误:

Command '['wkhtmltopdf', '--encoding', u'utf8', '--quiet', '/tmp/wkhtmltopdfQuoAXk.html', '-']' returned non-zero exit status 1 命令'['wkhtmltopdf','--encoding',u'utf8','--quiet','/tmp/wkhtmltopdfQuoAXk.html','-']'返回非零退出状态1

I think that wkhtmltopdf can't create the pdf, because the uwsgi request is not parse with HTML directly. 我认为wkhtmltopdf无法创建pdf,因为uwsgi请求不是直接用HTML解析的。

Do you think? 你认为?

I solve this problem with help of this comment: https://github.com/incuna/django-wkhtmltopdf/issues/67#issuecomment-120930906 我借助此评论来解决此问题: https : //github.com/incuna/django-wkhtmltopdf/issues/67#issuecomment-120930906

I changed in Django the STATIC_URL by default to: 我在Django中将STATIC_URL默认更改为:

STATIC_URL = 'http://domain.com/static/'

And I use "static" in templates as recommended the official documentation https://docs.djangoproject.com/en/1.8/howto/static-files/ : 我按照官方文档https://docs.djangoproject.com/en/1.8/howto/static-files/的建议在模板中使用“静态”:

{% load staticfiles %} and {% static 'js/jquery.min.js'%}" {% load staticfiles %}{% static 'js/jquery.min.js'%}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM