4teamwork/docxcompose

Standard example doesn't work.

Opened this issue · 0 comments

When i trying render a docx using standard example i get this error

Traceback (most recent call last):
  File "C:\Users\megak\Desktop\study\3 курс\practic 3\giga\main.py", line 10, in <module>
    doc.render(context)
  File "C:\Users\megak\Desktop\study\3 курс\practic 3\giga\venv\Lib\site-packages\docxtpl\template.py", line 382, in render
    for relKey, xml in headers:
  File "C:\Users\megak\Desktop\study\3 курс\practic 3\giga\venv\Lib\site-packages\docxtpl\template.py", line 338, in build_headers_footers_xml
    for relKey, part in self.get_headers_footers(uri):
  File "C:\Users\megak\Desktop\study\3 курс\practic 3\giga\venv\Lib\site-packages\docxtpl\template.py", line 324, in get_headers_footers
    for relKey, val in self.docx._part._rels.items():
                       ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DocumentPart' object has no attribute '_rels'. Did you mean: 'rels'?

My code:

from docxtpl import DocxTemplate

doc = DocxTemplate("t.docx")

context = {

    'text':"memememe"
}

doc.render(context)
doc.save(b"tesxt.docx")