Answer the question
In order to leave comments, you need to log in
How to output data from django to word template?
I have a website written in django. It is necessary to output some data to the doc document (it has some template, values from the database itself are substituted), so that later the text can be corrected and printed / saved. How can it be implemented? What to read/watch?
Answer the question
In order to leave comments, you need to log in
So google!
The first thing that Google searches for python docx template is the docxtpl library .
Under the hood, the python-docx library known in these circles is used for fiddling with documents + also popular jinja2 for, in fact, templating.
And yes - about .doc , the good old binary proprietary format, most likely, will have to be forgotten. .docx only .
If there is no possibility or desire to translate your template syntax into jinja2, then take python-docx directly and write the logic for replacing tokens in templates with the necessary values from the database yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question