How to stop continue numbering and restart everytime in word?

217 Views Asked by At

I am working on a word automation usingjinja2 templating engine with docxtpl. I wanted the enumeration to start with every time I create a new list in my document. I am not sure how to achieve that.

Code:

from docxtpl import DocxTemplate
import jinja2
_list = [{"name":"John Doe",'books':["first book","second book","third book"]},
       {"name":"Jane Smith",'books':["Jane first book","Jane's second book","Janes third book"]}]
doc = DocxTemplate("JinjaTemplates/listBooks.docx")
doc.render({"data":_list})
doc.save(f'test.docx')

In the Template1.docx:

{% for item in data %}

Books owned by {{ item.name }}
{% for book in item[‘books’] %}
1.  {{ book }} {% endfor %}
{% endfor %}

Right now, I get it like the following:

Books owned by John Doe

  1. first book
  2. second book
  3. third book

Books owned by Jane Smith

  1. Jane first book
  2. Jane's second book
  3. Janes third book

But the expected one is:

Books owned by John Doe

  1. first book
  2. second book
  3. third book

Books owned by Jane Smith

  1. Jane first book
  2. Jane's second book
  3. Janes third book
0

There are 0 best solutions below