Python error: No handlers could be found for logger “xhtml2pdf”

0 votes

I am converting an HTML to pdf in django function, for this i am using xhtml2pdf pisa module, and the code is

pdf = pisa.CreatePDF(html, file(settings.MEDIA_ROOT+'/tickets_pdf/'+pdfName, "w"))

This code is working and generates pdf but sometime it works and sometime it doesn't work and give error

No handlers could be found for logger “xhtml2pdf”

There is also same question on SO that I have already checked.

No handlers could be found for logger "xhtml2pdf"

But it did not work for me. If my client generates 10 times pdf then at least 4 times it gives this error and in other case it works fine. Is there any solution for this, or i have to generate pdf in other way.

Sep 5, 2018 in Python by bug_seeker
• 15,350 points
149 views

1 answer to this question.

0 votes
The only solution is to define a handler for xhtml2pdf in your settings file, as suggested by provided link.

The reason you get 500 error is because you have defined logger wrong. Check the app logs for errors, check the path to the log file that you have defined in settings.
answered Sep 5, 2018 by Priyaj
• 56,520 points

Related Questions In Python

0 votes
1 answer

Which IDE can be used for Python on Mac OS X

Have tried many different (Kate, Eclipse, Scite, ...READ MORE

answered Oct 15, 2018 in Python by SDeb
• 13,160 points
54 views
0 votes
1 answer

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,520 points
9,452 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
129 views
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 56,520 points
98 views
0 votes
1 answer

'Syntax Error: invalid syntax' for no apparent reason

You're missing a close paren in this ...READ MORE

answered Aug 13, 2018 in Python by Priyaj
• 56,520 points
66 views
0 votes
1 answer

What is the flow control for “continue” in python?

This is the way "continue" statement works! You ...READ MORE

answered Jul 16, 2018 in Python by Priyaj
• 56,520 points
48 views