Форум сайта python.su
проблема на гитхабе. без комментариев. либо мало кто пользуется, либо у всех работает…
settings.py: ... DEBUG = True ALLOWED_HOSTS = ['*'] WKHTMLTOPDF_CMD_OPTIONS = { 'margin-bottom': 10, 'margin-left': 20, 'margin-right': 10, 'margin-top': 10, } ...
settings.py: ... DEBUG = False ALLOWED_HOSTS = ['*'] WKHTMLTOPDF_CMD_OPTIONS = { 'margin-bottom': 10, 'margin-left': 20, 'margin-right': 10, 'margin-top': 10, } ...
[Mon May 26 11:27:20.750000 2014] [mpm_winnt:notice] [pid 1292:tid 1888] AH00354: Child: Starting 64 worker threads. Loading pages (1/6) [> ] 0% [======> ] 10% Error: Failed loading page file:///C:/windows/temp/wkhtmltopdfe9da0a.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to http error: 1201
views.py: from django.views.generic.base import View from wkhtmltopdf.views import PDFTemplateResponse class MyPDFView(View): template = None footer_template = 'pdf/footer.html' context = None filename = u'pdf' cmd_options = None def get(self, request): response = PDFTemplateResponse( request=request, template=self.template, footer_template=self.footer_template, filename=self.filename, context=self.context, show_content_in_browser=True, cmd_options=self.cmd_options, ) return response urls.py: ... from .views import MyPDFView urlpatterns = patterns('', url(r'^pdf/ttest/$', MyPDFView.as_view( filename=u'ttest-{}.pdf'.format(datetime.now().strftime('%Y_%m_%d_%H_%M_%S')), template='pdf/ttest.html', context=Context({ 'datetime': datetime_now, 'title': u'tt', 'context': Ttest.objects.all() }), )), ... )
Офлайн