M
M
Maxim Kovalev2021-06-03 17:52:26
Django
Maxim Kovalev, 2021-06-03 17:52:26

Doxtpl does not understand the encoding, how to fix it?

When substituting values ​​into a docx template using jinja2 and doxtpl, it gives the error "'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)"
How can I fix it?

The code is like this:

from docxtpl import DocxTemplate

    doc = DocxTemplate("./tracker/media/company2.docx")
    context = {'company_name':task_list}
    doc.render(context)
    src = "./tracker/media/Report_" + datetime.datetime.now().strftime(
        "%d_%m_%Y_%H:%M") + ".docx"

    doc.save(src)


Mistake:
60b8eca4d3f1a082276572.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2021-06-03
@pyHammer

Maxim Kovalev well, it seems to me that you should not use a colon in the file name

M
maksam07, 2021-06-04
@maksam07

https://stackoverflow.com/questions/21129020/how-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question