python-docx-template
python-docx-template copied to clipboard
AttributeError: 'InlineImage' object has no attribute 'current_rendering_part'
Please explain something about this error. I am getting this when I try to render my JSON. There are multiple InlineImage objects in that JSON.
I am also getting a similar issue!
please provide a fully runnig test case
@WilliamWCYoung I solved the issue in my case. If you share the way you are using it, maybe I would be able to help.
I also solved my own case - it was after bumping. For the use case I have I have a custom class which assumes certain behaviour. Thanks for a great project!
@rishi1804 @WilliamWCYoung Mind sharing how you fixed your issue? I'm running into the same error and am down the rabbit hole trying to debug what's going wrong. Could really use a nudge in the right direction.
So the solution I had was very specific to the changes I made on-top of the package (I had assumed behaviour of private internal variables). If you have similar custom logic, I would suggest that you add debugging and check that the variables are there and populated as you expect, if not you'll maybe need to call extra methods. For instance, and I'm not by my code now, there was an init method that was now being called through the normal flow that I was not being called in my use case.
Could you tell us what you changed in the code? I have the same problem but right now it is difficult for me to access the code of library
please provide a fully runnig test case
You must declare DocxTemplate prior to creating InLineImage e.g.,
first creating tpl instance here
tpl = DocxTemplate(f'C:\Python\template\{templateFileName}.docx')
later the JSON entry
{ 'image': InlineImage(tpl, imageFilePath, height=Inches(3.4), width=Inches(3.4*img.width/img.height)), 'label': f'PHOTO {phtoNameLetter}\n {item.properties["Photo_Caption"]}', })