Skip to content

settings

settings

Settings object, providing access to document-level settings.

Settings

Settings(
    element: BaseOxmlElement,
    parent: ProvidesXmlPart | None = None,
)

Bases: ElementProxy

Provides access to document-level settings for a document.

Accessed using the Document.settings property.

Source code in src/docx/settings.py
def __init__(self, element: BaseOxmlElement, parent: t.ProvidesXmlPart | None = None):
    super().__init__(element, parent)
    self._settings = cast("CT_Settings", element)
odd_and_even_pages_header_footer: bool

True if this document has distinct odd and even page headers and footers.

Read/write.

track_revisions property writable

track_revisions: bool

True when Word records changes made to this document as tracked changes.

Read/write. This is the "Track Changes" toggle. Setting it does not mark anything already in the document as a revision; it asks Word to record what happens from now on.

update_fields_on_open property writable

update_fields_on_open: bool

True when Word should recalculate every field when it opens this document.

Read/write. This library cannot compute a field result — a table of contents added here is empty, and a PAGE field has no page number, because both depend on how Word lays the document out. Setting this asks Word to fill them in as soon as the document is opened, which is the only way to get a populated table of contents out of a generated document.

Word prompts the reader before updating when the document has a table of contents, so a document saved with this set may show that prompt once.