-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
I am using python-docx-template to generate a word document report by populating my word template. Yesterday evening (before update 1.1.1), I ran my code and everything was working smoothly. Now, in the morning (after update 1.1.1) and I get an error when running the same code:
AttributeError Traceback (most recent call last)
File , line 90
89 template_vars {"name":"John", "lastname":"Oliver"}
---> 90 doc.render(template_vars)
92 doc.save("<path_to_save>".docx")
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:382, in DocxTemplate.render(self, context, jinja_env, autoescape)
379 # Headers
380 headers = self.build_headers_footers_xml(context, self.HEADER_URI,
381 jinja_env)
--> 382 for relKey, xml in headers:
383 self.map_headers_footers_xml(relKey, xml)
385 # Footers
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:338, in DocxTemplate.build_headers_footers_xml(self, context, uri, jinja_env)
337 def build_headers_footers_xml(self, context, uri, jinja_env=None):
--> 338 for relKey, part in self.get_headers_footers(uri):
339 xml = self.get_part_xml(part)
340 encoding = self.get_headers_footers_encoding(xml)
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:324, in DocxTemplate.get_headers_footers(self, uri)
323 def get_headers_footers(self, uri):
--> 324 for relKey, val in self.docx._part._rels.items():
325 if (val.reltype == uri) and (val.target_part.blob):
326 yield relKey, val.target_part
AttributeError: 'DocumentPart' object has no attribute '_rels'
Since, package python-docx-template specifies in their requirements.txt to install the latest version of all the required packages
six
python-docx
docxcompose
jinja2
lxml"
and does not specify which version, the newest update has broken it. Now, that I specified that I want python-docx == 1.1.0, the code started working again. Please help.