[ADD] utils / generate doc
This commit is contained in:
parent
0e3b590191
commit
50345c6c56
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
11
utils/docxtpl.py
Normal file
11
utils/docxtpl.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import io
|
||||||
|
from docxtpl import DocxTemplate
|
||||||
|
|
||||||
|
|
||||||
|
def get_document_from_values_stream(path_to_template: str, vals: dict):
|
||||||
|
doc = DocxTemplate(path_to_template)
|
||||||
|
doc.render(vals)
|
||||||
|
file_stream = io.BytesIO()
|
||||||
|
doc.save(file_stream)
|
||||||
|
file_stream.seek(0)
|
||||||
|
return file_stream
|
Loading…
x
Reference in New Issue
Block a user