[ADD] utils / generate doc

This commit is contained in:
Stepan Savelyev 2019-12-04 16:49:33 +05:00
parent 0e3b590191
commit 50345c6c56
2 changed files with 11 additions and 0 deletions

0
utils/__init__.py Normal file
View File

11
utils/docxtpl.py Normal file
View 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